Manually modifying single group navigation in BP 1.5

If your plugin or theme manually manipulates the navigation tabs in individual groups, either through the use of functions like bp_core_new_subnav_item() and bp_core_remove_subnav_item() or through the direct manipulation of $bp->bp_options_nav, you’ll want to know about some changes in BP 1.5.

Due to an oversight long ago, in BP 1.2.x, the key ‘groups’ (or, more precisely, $bp->groups->slug) was used to store two totally different nav items in $bp->bp_options_nav: the ‘Groups’ item on a user’s profile, and the main navigation of an individual group (Admin, Forums, Members, etc), an overlap that caused incorrect navigation to be rendered in some cases. In BP 1.5, this inconsistency has been rectified by moving individual group navigation items from $bp->bp_options_nav['groups'] to a new array position, keyed by the group slug. So if your group has the slug boone-for-president, the navigation for the Boone For President group will be stored at $bp->bp_options_nav['boone-for-president']

What does this mean for you? If you use the BP_Group_Extension class – which is true for the vast majority of plugins that create group navigation – you will not be affected (because the BP_Group_Extension class builds navigation for you, and takes this change into account). You may be affected if, like Jonnyauk was attempting to do, you’re using bp_core_remove_nav_item() to take stuff out of the group nav, like this:

function bbg_remove_send_invites_from_group() {
	global $bp;
	bp_core_remove_nav_item( $bp->groups->slug, 'send-invites' );
}
add_action( 'bp_setup_nav', 'bbg_remove_send_invites_from_group' );

which won’t work anymore. Do this instead:

function bbg_remove_send_invites_from_group() {
	bp_core_remove_nav_item( bp_get_current_group_slug(), 'send-invites' );
}
add_action( 'bp_setup_nav', 'bbg_remove_send_invites_from_group' );

Navigation for profiles, and elsewhere in BuddyPress, has not changed; the advice above is only relevant for groups (or custom components that have single items – Achievements comes to mind, meaning that if you are manually manipulating the single-Achievement subnav, you’ll need to make similar modifications.)