Skip to:
Content
Pages
Categories
Search
Top
Bottom

Is it Possible to Get the Current Group ID While in the Loop? (Continued because BP Forum Will Not L


  • frank tredici
    Member

    @frank13

    Out-of-the-box, BP has a Send Invites link on the Groups forum. We don’t want that link unless you are a Group Admin or Group Moderator. Currently, we only have 1 private group set at this time with a group moderator. It is Group 17. But I know we will be getting more and more of these instances and I want to avoid hard coding the Groups each time to control the Send Invites link.

    See my code below from a plug-in I wrote:

    My plug-in:

    `
    function bbg_remove_send_invites_from_group() {

    if ($_SERVER == ‘123.456.789.10’) { // my test — does not work
    global $bp;
    $guid = $bp->group->id;
    echo ‘>>’.$guid.'<>’.bp_group_id().'<<';
    exit;
    }

    //bp_core_remove_nav_item( bp_get_current_group_slug(), ‘send-invites’ );
    $guid = ’17’; //Group ID for Bob’s Private Group
    if (is_site_admin()) return;
    elseif (groups_is_user_mod( get_current_user_id(), $guid ) == “1”) return;
    elseif (groups_is_user_admin( get_current_user_id(), $guid ) == “1”) return;
    else bp_core_remove_subnav_item( bp_get_current_group_slug(), ‘send-invites’ );
    }

    add_action( ‘bp_setup_nav’, ‘bbg_remove_send_invites_from_group’ );
    `

Viewing 5 replies - 1 through 5 (of 5 total)

  • modemlooper
    Moderator

    @modemlooper

    you only need

    `if ( !bp_is_group_admin())
    bp_core_remove_subnav_item( bp_get_current_group_slug(), ‘send-invites’ );`


    frank tredici
    Member

    @frank13

    @modemlooper,

    I get `HTTP 500 Internal Server Error` on that statement.

    I am running WP 3.4.2 and BP 1.5.6


    frank tredici
    Member

    @frank13

    Anyone — is it possible to know the Group ID during the Loop?


    modemlooper
    Moderator

    @modemlooper

    You already know how to get it, your code may not be correct or enough to use it to do what you want. I did not try it, if I have time I’ll look into it. Is this really the loop or just each group?

    Another option you may want to try is to remove the item for every one then add it back for just admins. You may have to write a bit more logic to your code:

    if (on the current group && current user = group admin)
    add sub nav


    frank tredici
    Member

    @frank13

    @modemlooper,

    “Is this really the loop or just each group?”

    Let’s put it this way … whenever I cycle through all groups and whenever I cycle through a single group, my plug-in takes effect. I know that because my latest attempt to get it to work was using your code and I got a Server 500 Error in both instances (in my terms “loops”).

    Bottom-line, I am just trying to capture what I think should be available in the Group ID (at least I would think it should be there). I don’t want to write more code. I’ll just hard code it as we go. Not the most ideal solution,but then again….it is Buddypress.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Is it Possible to Get the Current Group ID While in the Loop? (Continued because BP Forum Will Not L’ is closed to new replies.
Skip to toolbar