Skip to:
Content
Pages
Categories
Search
Top
Bottom

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

  • Avatar of admin25
    admin25
    Participant

    @admin25

    Hello,
    New to buddypress and coding.
    I need to limit “The Group Loop” to just the groups the user is a member of.
    Trying this but not working (also tried goggling this but no luck)

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • Avatar of shanebpdev
    shanebp
    Participant

    @shanebp

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

    You need to pass the actual user id. Try this:
    `
    loggedin_user->id ) ) : ?>
    `

    Avatar of admin25
    admin25
    Participant

    @admin25

    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.

    Avatar of shanebpdev
    shanebp
    Participant

    @shanebp

    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.

    Avatar of admin25
    admin25
    Participant

    @admin25

    Thanks, that worked.

    Much appreciated.

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

You must be logged in to reply to this topic.