This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// this is to add a fake component to BuddyPress. A registered component is needed to add notifications | |
function custom_filter_notifications_get_registered_components( $component_names = array() ) { | |
// Force $component_names to be an array | |
if ( ! is_array( $component_names ) ) { | |
$component_names = array(); | |
} | |
// Add 'custom' component to registered components array |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function pat_filter_notifications_get_registered_components( $component_names = array() ) { | |
if ( ! is_array( $component_names ) ) { | |
$component_names = array(); | |
} | |
array_push( $component_names, 'events' ); | |
return $component_names; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Paste in your theme functions.php or in bp-custom.php. | |
* Load the site in a browser | |
* Remove from your theme functions.php or bp-custom.php. | |
*/ | |
function buddypress_add_last_activity() { | |
$members = get_users( 'fields=ID' ); | |
// $members = get_users( 'fields=ID&role=subscriber' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Remove init rest routes | |
remove_action( 'rest_api_init', 'create_initial_rest_routes', 0 ); | |
// Remove oembed rest routes | |
function remove_json_api () { | |
// Remove the REST API lines from the HTML Header | |
remove_action( 'wp_head', 'rest_output_link_wp_head', 10 ); | |
remove_action( 'wp_head', 'wp_oembed_add_discovery_links', 10 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
If you are using BP 2.1+, this will insert a Country selectbox. | |
Add the function to bp-custom.php and then visit .../wp-admin/users.php?page=bp-profile-setup | |
Remove this function after the field is created. | |
*/ | |
function bp_add_custom_country_list() { | |
if ( !xprofile_get_field_id_from_name('Country') && 'bp-profile-setup' == $_GET['page'] ) { | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* example of using BP_Group_Extension | |
* replace 'test' with something else - remember that it is case-sensitive | |
* checks for any selected Group Types in the 'Settings' step | |
*/ | |
function test_add_group_extension() { | |
if ( bp_is_active( 'groups' ) ) : |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'bp_setup_nav', 'add_videos_subnav_tab', 100 ); | |
function add_videos_subnav_tab() { | |
global $bp; | |
bp_core_new_subnav_item( array( | |
'name' => 'Videos', | |
'slug' => 'videos', | |
'parent_url' => trailingslashit( bp_loggedin_user_domain() . 'friends' ), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function shanebp_user_groups(){ | |
$group_ids = groups_get_user_groups( bp_get_member_user_id() ); | |
foreach( $group_ids["groups"] as $id ) { | |
$group = groups_get_group( array( 'group_id' => $id ) ); | |
echo '<a href=' . trailingslashit( bp_get_groups_directory_permalink() . $group->slug . '/' ) . '>' . $group->name . '<a/><br>'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Using the Nouveau template pack | |
// Add a count bubble on a custom tab on a user profile is straightforward | |
$count = get_the_count_profile( $group_id ); | |
$class = ( 0 === $count ) ? 'no-count' : 'count'; | |
$name = sprintf( __( 'Events <span class="%s">%s</span>', 'bp-simple-events' ), esc_attr( $class ), number_format_i18n( $count ) ); | |
NewerOlder