0

How to get users already joined group count by user-id or username in BuddyPress.

For example,

In the member listing page, in the members loop, I like to get users group count and display in the grid.

0

To get the group count, use groups_get_user_groups. Find it in: buddypress\bp-groups\bp-groups-functions.php

In the members loop, the member id is provided via: bp_member_user_id()

You will need to check the member-loop template to find out how to hook into the loop. Or overload that template in your child theme and add a do_action wherever you want it.

Once you have a hook, use it to call something like this:

function get_group_count_for_member() { 

    $groups_for_member = groups_get_user_groups( bp_member_user_id() );

    echo 'Groups: ' . $groups_for_member['total'];

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.