Skip to:
Content
Pages
Categories
Search
Top
Bottom

How can I get a group ID that displayed user is joining?


  • Olivia
    Participant

    @oliviabuddy

    Hello everyone, I’m very new to buddypress and PHP.
    I’m stuck to get a group ID that displayed user is joining.
    What exactly I’m trying to do is to change a CSS class if the user is joining specific group.

    I’m guessing it’s gonna be like this:

    if( [group ID that displayed user is joining] == 1){
    echo ‘

    ‘;
    } else {
    echo ”

    ;
    }

    Any ideas?
    Thanks!

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

  • Olivia
    Participant

    @oliviabuddy

    Oops, HTML tags are disappeared! I wanted to say

    if( [group ID that displayed user is joining] == 1){
    echo ‘<div class="classA">‘;
    } else {
    echo ‘<div class="classB">’;
    }


    r-a-y
    Keymaster

    @r-a-y

    Depending on the context you’re using this in, this might not work correctly but try:
    bp_get_group_id()

    or:

    global $bp;
    $bp->groups->current_group->id;


    Olivia
    Participant

    @oliviabuddy

    Thanks ray,
    I tried both

    <?php if ( bp_get_group_id(1) ) { echo ‘yes’; } ?>

    and

    <?php global $bp; if ( $bp->groups->current_group->id == 1 ) { echo ‘yes’; } ?>

    but they are not working…

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How can I get a group ID that displayed user is joining?’ is closed to new replies.
Skip to toolbar