Hi David,
Hoping I’ll be able to help. I’ve seen alot of questions on the topic of How To Change and Reorder BuddyPress Group tabs and not much great direction. Hopefully you won’t be saying that after my posts… What I’m really hoping is someone comes in with a simpler, more elegant solution 🙂
Were you able to control the standard tabs?
For the standard group tabs, you can control them directly like this:
if (isset($bp->groups->current_group->slug) && $bp->groups->current_group->slug == $bp->current_item)
{
$bp->bp_options_nav[$bp->groups->current_group->slug]['home']['position'] = 10;
$bp->bp_options_nav[$bp->groups->current_group->slug]['members']['position'] = 60;
$bp->bp_options_nav[$bp->groups->current_group->slug]['notifications']['position'] = 110;
}
So the code to put in functions.php might look like this:
function whff_setup_nav()
{
if (isset($bp->groups->current_group->slug) && $bp->groups->current_group->slug == $bp->current_item)
{
$bp->bp_options_nav[$bp->groups->current_group->slug]['home']['position'] = 10;
$bp->bp_options_nav[$bp->groups->current_group->slug]['members']['position'] = 60;
$bp->bp_options_nav[$bp->groups->current_group->slug]['notifications']['position'] = 110;
}
}
add_action( 'bp_setup_nav', 'whff_setup_nav', 100000 );
CUSTOM BUDDYPRESS GROUP TABS
Now, the non-standard tabs are the tricky ones. You can’t access them through $bp->bp_options_nav (at least I couldn’t figure out how to do this.)
Nonstandard Group tabs through the $wp_filter global. A good starting point is to dump the $wp_filter variable and get a look at it’s guts. Add this code in functions.php:
global $wp_filter;
foreach ( (array)$wp_filter as $key => $value )
{
echo '<pre>';
echo '<strong>' . $key . ': </strong><br />';
print_r( $value );
echo '</pre>';
}
$wp_filter is a bunch of nested arrays. Search through the output for your Group Tab Names (i.e. search for “Calendar”) and you will find something like this:
[00000000746c6153000000004e38ec1f_register] => Array
(
[function] => Array
(
[0] => BP_Group_Calendar_Extension Object
(
[visibility] => private
[enable_create_step] =>
[enable_nav_item] => 1
[enable_edit_item] =>
[name] => Calendar
[slug] => calendar
[admin_name] =>
[admin_slug] =>
[create_name] =>
[create_slug] =>
[create_step_position] => 81
[nav_item_position] => 40
[nav_item_name] =>
[display_hook] => groups_custom_group_boxes
[template_file] => groups/single/plugins
)
[1] => _register
)
[accepted_args] => 1
)
That’s your Group tab and all the hooks you need to change attributes (in this case it’s the tab that says “Calendar”.)
But… unfortunately you can’t use the [00000000746c6153000000004e38ec1f_register] as a handle — that string is random and changes every time. But, now you know the class name is BP_Group_Calendar_Extension Object and you can search for that in the $wp_filter array and make the changes.
Hope this gets you closer, let me know how you make out. Cheers David!