Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Using WP 3.9.1 and BuddyPress 2.0.1.

I want to add a subnav item to the "groups" tab that takes you to the "create a new group" page.

I have the following functions:

add_action( 'bp_setup_nav', 'ecomukti_add_create_village_subnav_tab', 100 );

function ecomukti_add_create_village_subnav_tab() {
global $bp;

bp_core_new_subnav_item( array(
'name' => 'Create Virtual Village',
'slug' => 'create',
'parent_url' => trailingslashit( 'step/group-details' ),
'parent_slug' => 'groups',
'screen_function' => 'ecomukti_create_village_screen',
'position' => 50
)
);
}

function ecomukti_create_village_screen() {
bp_core_redirect( get_option('siteurl') . "groups/create/step/group-details/" );
}

For the most part, this works fine - it correctly adds the subnav item. However, the problem is with my screen_function. It seems to totally ignore the screen_function. The URL created by bb_core_new_subnav_item() is http://mysite.com/members/membername/groups/step/group-details/create/ - obviously that page doesn't exist, and I really want to go to http://mysite.com/groups/step/group-details/create/ That's why my screen_function is a redirect. But no matter what I put in bp_core_redirect, the redirect doesn't happen - it still goes to http://mysite.com/members/membername/groups/step/group-details/create/ So what am I doing wrong? How can I get this function to properly redirect to the "create group" page?

share|improve this question

closed as off-topic by kaiser Jul 30 at 19:10

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.

1 Answer 1

up vote 1 down vote accepted

You can force the link. Try:

bp_core_new_subnav_item( array(
      'name'            => 'Create Virtual Village',
      'slug'            => 'create',
      'parent_url'      => 'groups',
      'parent_slug'     => 'groups',
      'screen_function' => 'false',
      'position'        => 50,
      'link'            => get_option('siteurl') . '/groups/create/step/group-details/'
      )
);
share|improve this answer
    
Yes, that works! Thank you! –  Gwendydd May 18 at 1:08

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