Set default filter for BuddyPress Activity
If you need to change the default activity filter from Everything to something else, you can do that easily.
Here is an example where I am setting the BuddyPress default activity filter to activity updates.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | /** * Set Default BuddyPress Activity filter. */ function buddydev_set_default_activity_filter() { // If the filter is already set, do not do anything ok. if ( isset( $_COOKIE['bp-activity-filter'] ) ) { return ; } // additional check for activity dir and profile activity. if ( ! bp_is_activity_directory() && ! bp_is_user_activity() ) { return ; } // Possible filters // 'new_member' // 'updated_profile' // 'activity_update' // 'friendship_accepted' //'friendship_created' // 'created_group' // 'joined_group' // 'new_blog_post' // 'new_blog_comment' etc. $filter = 'activity_update'; // Set filter to our respective filter., // In this case, I am setting filter to the 'Updates' filter setcookie( 'bp-activity-filter', $filter,null, '/' ); $_COOKIE['bp-activity-filter'] = $filter; } add_action( 'bp_template_redirect', 'buddydev_set_default_activity_filter' ); |
You can change that and set to anything else(Make sure you are using a valid filter key). The important thing to remember here is that you will see the 'bp-activity-filter' to the update you want to see as default.
Have fun!
Hello,
Will this snippet affect only the site wide activity page, I don't want it to affect members activity.
Members activity filter should = everything
Site wide activity filter should = updates only
Please change this
to
and it will work as expected.
Where can I add this? On the buddypress php file?
Please put it in your theme/chind theme's functions.php or in wp-content/plugin/bp-custom.php