Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] List current users memberships


  • eikeco
    Participant

    @eikeco

    How do I list the current logged in users Group Memberships in sidebar.php?
    I am trying to create a “My groups” list to be shown in the sidebar on all pages.

    The groups-loop.php displays all groups. I only want the ones the logged in users is a member of.

    Your help is much appreciated.

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

  • shanebp
    Moderator

    @shanebp

    The groups loop takes various parameters.
    More info from the codex:

    Groups Loop

    Try this:
    bp_has_groups( 'user_id=' . bp_loggedin_user_id() )


    eikeco
    Participant

    @eikeco

    @shanebp thank you. That’s the parameters I was looking for.
    This lists all the logged in users memberships.

    The only problem I found was when on a groups page the list only shows the group you are viewing. It looks like the loop is being effected on this page. I don’t know how though as the 2 loops on the page are clearly split. Any ideas on how to work around this?

    Example on every page:

    – My Group 1
    – My Group 2
    – My Group 3
    – My Group 4

    Example while viewing “My Group 2” page:

    – My Group 2
    (we are missing the full list)


    danbp
    Participant

    @danbp

    hi @eikeco

    you can use this widget.
    Download the file and rename it to bp-my-groups-widget.php
    Add the file to wp-content/plugins/ and activate it.
    Go to appearence > widgets and pull it somewhere to your theme. Enjoy.


    eikeco
    Participant

    @eikeco

    Hi @danbp!

    Thank you. That worked! Giving that a star on Gist 🙂

    Thanks again.


    danbp
    Participant

    @danbp

    You’re welcome. Merci for the star !

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Resolved] List current users memberships’ is closed to new replies.
Skip to toolbar