Are you using the BuddyPress for online communities, teams, and groups with your WordPress websites and want to get the current logged in the user’s list. This is a simple and short tutorial in which I have shared a BuddyPress code snippet to help all BuddyPress developers.
Use below code in your template page to display the group of Current Logged in Users in BuddyPress WordPress site.
/* Is the user in any teams */
$user_id = get_current_user_id();
$args = array(
'user_id' => $user_id
if ( bp_has_groups( $args) ) :
< ?php while ( bp_groups() ) : bp_the_group(); ?>
<a href="<?php bp_group_permalink(); ?>">< ?php bp_group_avatar( 'type=full' ); ?>
<h5>< ?php bp_group_name(); ?></h5>
< ?php endwhile; ?>
< ?php else: /* If the user is not in any teams */?>
< ?php endif; ?>
Prem Tiwari is the founder of FreeWebMentor.com and also a professional developer who has vast experience in PHP and open source technologies. Apart from this, he is a blogger by hobby and also he has been a regular speaker of WordPress sessions in various IT Companies. View all posts by Prem Tiwari