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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | <?php /* Is the user in any teams */ $user_id = get_current_user_id(); $args = array( 'user_id' => $user_id ); if ( bp_has_groups( $args) ) : ?> <ul> < ?php while ( bp_groups() ) : bp_the_group(); ?> <li> <div class="t-m-list"> <a href="<?php bp_group_permalink(); ?>">< ?php bp_group_avatar( 'type=full' ); ?> <h5>< ?php bp_group_name(); ?></h5> </a> </div> </li> < ?php endwhile; ?> </ul> < ?php else: /* If the user is not in any teams */?> <p>No teams</p> < ?php endif; ?> |
If you like this tutorial, then like and share this tutorial with your friends, and don’t forget to follow us on Facebook and Twitter to learn cool WordPress tutorials.
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.
Article Tags: buddypress tutorial, wordpress tutorial, wordpress tutorial for beginner, wordpress tutorial for beginners, wordpress tutorials, wordpress tutorials for beginners, wordpress tutorils