[Resolved] How to create Loop from groups_get_user_groups output
I am trying to create a widget that would show the list of groups that a particular user is a member of. I have created this:
<?php $user_id = get_current_user_id(); $user_groups = (groups_get_user_groups($user_id)); $user_groups = $user_groups["groups"]; ?> <ul class="my-groups-list" class="item-list"> <?php foreach ($user_groups as $group): ?> <li><?php echo $group ?></li> <?php endforeach; ?> </ul>
This code displays a list of the user’s group ID’s. Now I would like to create a loop from this query, so that I could display the group permalinks and names instead of the ID, like this:
<ul class="my-groups-list" class="item-list"> <?php while ( ... something() ) : bp_the_group(); ?> <li><a href="<?php bp_group_permalink() ?>"><?php bp_group_name() ?></a></li> <?php endwhile; ?> </ul>
How can I do that?
I use WordPress 4.0 and BuddyPress 2.0.2.
Thanks for your help.
- The topic ‘[Resolved] How to create Loop from groups_get_user_groups output’ is closed to new replies.