Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] How limit ”The Group Loop” to just the groups the user is a member of

  • @admin25

    Participant

    Hello,
    New to buddypress and coding.
    I need to limit “The Group Loop” to just the groups the user is a member of.

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • @shanebp

    Moderator

    Your answer is in the codex:
    https://codex.buddypress.org/developer-docs/custom-buddypress-loops/the-groups-loop/

    You need to pass the actual user id. Try this:

    
    loggedin_user->id ) ) : ?>
    

    @admin25

    Participant

    Hello shanebp, thanks for the response.

    I tried replacing the 1st line of code in the “groups loop”

    with your line of code
    loggedin_user->id ) ) : ?>
    but it still gives me all groups.

    @shanebp

    Moderator

    Try this:

    
    <?php
    global $bp;
    $user_id = $bp->loggedin_user->id;
    echo "user_id=" . $user_id;
    if ( bp_has_groups( 'max=20&user_id='  .  $user_id ) ) :
    ?>
    

    If $user_id echos a blank, then you have other problems in your file.

    @admin25

    Participant

    Thanks, that worked.

    Much appreciated.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Resolved] How limit ”The Group Loop” to just the groups the user is a member of’ is closed to new replies.
Skip to toolbar