/**
* Set default activity directory tab for BuddyPress
*/
function reign_set_default_activity_directory_tab() {
// If user is not logged in or
// If the scope is already set, do not do anything ok.
if ( ! is_user_logged_in() || isset( $_COOKIE['bp-activity-scope'] ) ) {
return ;
}
// additional check for activity dir
if ( ! bp_is_activity_directory() ) {
return ;
}
$tab = 'groups'; // 'all', 'friends', 'groups', 'mentions'
// Set scope to our needed tab,
// In this case, I am setting to the 'friends' tab
setcookie( 'bp-activity-scope', $tab,null, '/' );
$_COOKIE['bp-activity-scope'] = $tab;
}
add_action( 'bp_template_redirect', 'reign_set_default_activity_directory_tab' );
Comments