Reply To: help with default activity stream tab
You’re talking about 2 different things: profile and groups. Let me explain you a little…
On the buddy nav bar, navigation looks similar but doesn’t work the same way on profile and on group page. While profile navigation use nav and sub-nav, the group navigation use only sub-nav.
Also, as documented on codex, define('BP_DEFAULT_COMPONENT', '...' ); is a constant related to a component, not a sub-nav tab. It let you define the default landing component, but not the one or other sub-nav tab. For example on profiles, the component Activity has 4 sub-nav attached to it: personnal, mentions, favorites, friends, groups
To get one of them, you need to specify a new default tab, not another component. 🙂
Buddybar main nav items on profile page
Activity Profile Friends Groups Forums (if you use group forums)
Default tab is Activity/personnal. To change it for “Friends” you use the constant:
define('BP_DEFAULT_COMPONENT', 'friends' );
To change the default landing tab from (Component/sub-tab). For example Activity/personnal to Activity/mentions, you define a new nav default tab with a function like this one:
function bpex_set_member_default_nav() {
bp_core_new_nav_default (
array(
'parent_slug' => buddypress()->activity->id,
// other "activity" sub_nav slugs : personal favorites friends groups
'subnav_slug' => 'mentions',
'screen_function' => 'bp_activity_screen_mentions'
)
);
}
add_action( 'bp_setup_nav', 'bpex_set_member_default_nav', 20 );
For groups, it’s a similar technique, but a different syntax. The following example is a bit sophisticated, as it let you change the landing tab differently for each defined group.
Depending each group activity or target, you can choose a different default tab.
In this example, the kill bill group has Forum as landing tab, while Leon’s group use the group member directory.
function bpex_custom_group_default_tab( $default_tab ){
/**
* class_exists() is recommanded to avoid problems during updates
* or when Groups Component is deactivated
*/
if ( class_exists( 'BP_Group_Extension' ) ) :
$group = groups_get_current_group();//get the current group
if( empty( $group ) ) {
return $default_tab;
}
switch($group->slug){
case 'kill-bill': // group name (use slug format)
$default_tab='forum';
break;
case 'leon':
$default_tab='members';
break;
default:
$default_tab='home';// the default landing tab
break;
}
return $default_tab;
endif; // end if ( class_exists( 'BP_Group_Extension' ) )
}
add_filter('bp_groups_default_extension','bpex_custom_group_default_tab');
All this tested and working with BP 2.7.2 / Twenty Sixteen