WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

question: I am trying to create a new sub nav item for the groups on buddy press I am using bp_core_new_subnav_item to do it and passing the screen_function, but the tab is not displaying on the group page

Any ideas where I should be looking on this?

Heres our code.

bp_core_new_nav_item( array(
  'name' => 'Document List',
  'slug' => 'group-document-list',
  'parent_url' => $bp->loggedin_user->domain . $bp->groups->slug . '/',
  'parent_slug' => $bp->groups->slug,
  'screen_function' => 'group_document_list_function_to_show_screen',
  'position' => 55 ) );

  function group_document_list_function_to_show_screen() {

   //add title and content here - last is to call the members plugin.php template
   add_action( 'bp_template_title', 'group_document_list_function_to_show_screen_title' );
   add_action( 'bp_template_content', 'group_document_list_function_to_show_screen_content' );
   bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
function group_document_list_function_to_show_screen_title() {
    echo 'Documents for this group';
function group_document_list_function_to_show_screen_content() {
share|improve this question

closed as off-topic by Pieter Goosen, gmazzap, kaiser Aug 4 '14 at 16:48

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

Can you please edit your question and add the code that you're using? – Boone Gorges Mar 21 '12 at 1:51
wordpress.stackexchange.com/questions/6719/… this is what we tried and it didnt work. We are thinking maybe its some plugin thats blocking the space where the tab would show up maybe? ok trying to edit my post. – Joseph Mar 21 '12 at 2:01
Hope thats what you needed. Thanks Boone! – Joseph Mar 21 '12 at 3:04
up vote 2 down vote accepted

Make sure that you only attempt to set up the items after BP has set up its core navigation. You can ensure this by hooking to bp_setup_nav with a priority higher than 10.


function bbg_setup_nav() {
    bp_core_new_subnav_item( array( 
        'name' => 'Document List',
        'slug' => 'group-document-list',
        'parent_url' => $bp->loggedin_user->domain . $bp->groups->slug . '/',
        'parent_slug' => $bp->groups->slug,
        'screen_function' => 'group_document_list_function_to_show_screen',
        'position' => 55
    ) );
add_action( 'bp_setup_nav', 'bbg_setup_nav', 100 );

Keep in mind that, as written, this code is intended to add a subnav tab to the Groups subnav of a user profile. If you want to attach it to a single group instead, you need to relativize it to groups, using a different parent_slug and parent_url:

// ...
'parent_slug' => bp_get_current_group_slug(),
'parent_url'  => bp_get_group_permalink( groups_get_current_group() )
// ...

To be honest, though, if you want to be adding subnav items to BP Groups, your best bet is to use the BP Group Extension API http://codex.buddypress.org/developer-docs/group-extension-api/. You just fill in a few methods, and all the BP-specific navigation logic is done for you. If there are methods (like create_screen() you're not going to use, just leave them blank.

share|improve this answer
In reviewing your original code, I realized that you used the wrong function - bp_core_new_nav_item() instead of bp_core_new_subnav_item(). The former is used for adding components to user profiles. For groups, the latter must be used. I've updated my answer accordingly. – Boone Gorges Mar 22 '12 at 1:50
Thank you this was very helpful Boone. I am new to this website so I didnt see how to "Accept" answers or I would have before. – Joseph Apr 4 '12 at 16:00
Thank you so much! Took me a while to find this :) – Norris Jun 16 '12 at 8:54
@BooneGorges can you include an example of how to do this using the BP Group Extension API on my post here: wordpress.stackexchange.com/questions/223416/…? This is what I'm trying to do, but I figured as you suggested here, that with the group extension API I should be using that, just can't find documentation that shows how to create subnavs tabs. – Xtremefaith Apr 12 at 7:43
@Xtremefaith The language here is confusing. The code above explains (a) how to add a subnav to a user's Groups nav, and (b) how to add a nav to a specific group. It so happens that BP implements group nav in the same way as a profile subnav. BP currently has no direct way in the API to create visual subnav items (they'd technically be sub-subnavs) in groups. See bp-templates/bp-legacy/buddypress/groups/single/admin.php and bp_groups_admin_tabs() to see a workaround. – Boone Gorges Apr 13 at 13:41

Not the answer you're looking for? Browse other questions tagged or ask your own question.