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.)
Boone B. Gorges 9:24 pm on September 5, 2011 Permalink |
I forgot to mention that if you need to keep 1.2.x compatibility in a plugin, you can try this method:
$parent_slug = isset( $bp->bp_options_nav[$bp->groups->current_group->slug] ) ? $bp->groups->current_group->slug : $bp->groups->slug;
bp_core_remove_nav_item( $parent_slug, 'send-invites' );
That should cover both 1.2.x and 1.5+.
Tim Carey 10:16 pm on October 28, 2011 Permalink |
Try this method where
Leland 5:22 pm on January 11, 2012 Permalink |
Boone,
Could you put in the full code for this? I have been trying to hack this updated group tab code for hours and nothing is working. Adding to functions file. Thanks.
Stas Sușcov 10:45 pm on September 5, 2011 Permalink |
Another thing to mention, since this post was about group component, if you were using in your plugins
$bp->groups->slugto check for current page component, you should change that to$bp->groups->idsince slug and component id refer to absolutely different information:1. to group component permalink slug
2. to group component id itself
As an example, if you’ve mapped groups component to a page called classes, your code will never work!
Johan 10:28 pm on September 27, 2011 Permalink |
Thanks for the info, guys. Can you please give me an example of how to ADD stuff to the menu option, as well?
Cheers
Tim Carey 9:50 pm on October 28, 2011 Permalink |
Could someone please explain how to use bp_groups_default_extension to make your default group tab
Johnny 5:12 am on November 2, 2011 Permalink |
Also, could someone explain how to change a group tab slug too?
Cheers
Johnny
Chris 8:12 pm on April 29, 2012 Permalink |
Hi Boone,
In your original post I think you have an error after ‘Do this instead:’ ….
bp_core_remove_nav_item(….
should read:
bb_core_remove_subnam_item(…
I’m also interested in what method you would recommend using for re-ordering the subnav items, e.g. renaming ‘Home’ to ‘Activities’ and moving ‘Forum’ to the start of the sub-nav
And also changing the default subnav item (e.g. to Forum) in the example above, so that all other links to the group default to that subnav?
Kind regards
Chris
Chris 8:15 pm on April 29, 2012 Permalink |
(ignore this reply – I forgot to click notify boxes before I clicked reply)
Irmy 11:59 am on October 28, 2012 Permalink |
indisputable very good informative, good explanation! thanks
Vexpress 7:47 am on November 7, 2012 Permalink |
great info! …any idea how to add stuff to menu option?
make money using 3:48 pm on March 20, 2013 Permalink |
I am really impressed together with your writing abilities
and also with the format on your blog. Is this a paid subject matter or did you customize it yourself?
Either way keep up the nice high quality writing, it’s uncommon to peer a great weblog like this one today..
Chris 4:16 pm on April 18, 2013 Permalink |
You need a (better?) spam filter, Boone…. Time to unsubscribe