Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
AppCommunity member list filter
<?php
// Add groups to member list
// add this code to a custom plugin
function app_extend_bp_member($response, $request, $user) {
$joined_groups = array();
$group_ids = groups_get_user_groups($user->ID);
foreach($group_ids['groups'] as $id) {
$current_group = groups_get_group(array('group_id' => $id));
if($current_group->name !== 'hidden') {
$joined_groups[] = $current_group->name;
}
}
if (!empty($joined_groups)) {
$response->data['after_item'] = '<span class="joined-groups"><strong>Groups:</strong> ' . implode (", ", $joined_groups) . '</span>';
}
return $response;
}
add_filter('bp_rest_members_prepare_value', 'app_extend_bp_member', 10, 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment