Skip to:
Content
Pages
Categories
Search
Top
Bottom

Adding Subnav Link to Group Pages

  • @crashutah

    Participant

    Under groups, I’m trying to add a subnav link to a non group page using a plugin. I got some code to work, but it seems like there should be a way a simpler way to do it. Here’s my code:
    function send_invites_email_redirect() {

    $redirect_url_cc = bp_loggedin_user_domain() . BP_INVITE_ANYONE_SLUG . ‘/invite-new-members/group-invites/’ . bp_get_group_id() ;
    bp_core_redirect($redirect_url_cc);
    }

    function bp_send_invites_by_email_setup_nav() {

    global $bp;
    $group_link = $bp->root_domain . ‘/’ . $bp->groups->slug . ‘/’ . $bp->groups->current_group->slug . ‘/’;

    bp_core_new_subnav_item(
    array(
    ‘name’ => __( ‘Send Invites by Email’, ‘bp-invite-anyone’ ),
    ‘slug’ => ‘send-invites-by-email’,
    ‘parent_url’ => $group_link,
    ‘parent_slug’ => $bp->groups->slug,
    ‘screen_function’ => ‘send_invites_email_redirect’,
    ‘position’ => 65,
    ‘item_css_id’ => ‘send-invites-by-email’
    )
    );
    }
    add_action( ‘wp’, ‘bp_send_invites_by_email_setup_nav’, 2 );

    Also, is there any way to pass a variable to the function bp_core_new_subnav_item() calls? Looks like the bp_get_group_id() doesn’t get a value for some reason. Probably because it’s no longer on a group page when the function gets called.

Viewing 5 replies - 1 through 5 (of 5 total)
  • @crashutah

    Participant

    I’m not sure why bp_get_group_id() wasn’t working in the above function, but this works instead: $bp->groups->current_group->id

    That still leaves these questions:
    1. Is there a simpler way to add an external link to the Group Subnav menu than the code above?
    2. Can you pass variables into the “screen_function” that the nav calls?

    @boonebgorges

    Keymaster

    I think the answers are:
    (1) No
    (2) No
    :)

    (2) means you’ll have to rebuild stuff like $group_link once you get into the screen function.

    @crashutah

    Participant

    Thanks Boone. I didn’t think so either. Is this worthy of putting in Trac as an enhancement request. Maybe not since there is a solution that works. It’s just a little ugly.

    P.S. Do you like how the above function adds a group link straight to the invite by email in your Invite Anyone plugin? Everything I know I learned from Boone’s Invite Anyone plugin…lol.

    @boonebgorges

    Keymaster

    heh heh…I am an educator at heart.

    I think a good enhancement would be to allow dummy tabs, ie tabs that go to a more-or-less hardcoded URL (which is essentially what you have above). That could either be another argument in bp_core_new_subnav_item or another function like bp_core_new_subnav_link().

    @crashutah

    Participant

    Sounds good. I just created my first Trac ticket: https://trac.buddypress.org/ticket/2389 I think that’s where all the cool people hang out.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Adding Subnav Link to Group Pages’ is closed to new replies.
Skip to toolbar