Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottopolis/e5d9fc1f195dcdac8f0eacb7f6ddbd38 to your computer and use it in GitHub Desktop.
Save scottopolis/e5d9fc1f195dcdac8f0eacb7f6ddbd38 to your computer and use it in GitHub Desktop.
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