 
                            Are you looking for a way to enables you to display the list of groups the current logged in user’s joined? While there’s probably a plugin for this, we have created a quick code snippet that you can use to display the list of joined groups in WordPress.
Instructions:
All you have to do is add this code to your theme’s sidebar.php file or menu.php file:
<?php
    $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' ); ?><?php bp_group_name(); ?></a>
        </div>
      </li>
    <?php endwhile; ?>
    </ul>
  <?php endif; ?>
Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly copy / paste code snippets in WordPress, so you don’t accidentally break your site.
If you liked this code snippet, please consider checking out our other articles on the site like: 27 best WordPress business themes and how to fix the error establishing a database connection.
 
        
Comments Leave a Reply