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.
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.
Share Improve this question asked Mar 2, 2020 at 22:19 Gnanasekaran LoganathanGnanasekaran Loganathan 1216 bronze badges1 Answer
Reset to default 0To 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'];
}
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744693013a4588322.html
评论列表(0条)