Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@shanebp
Created July 22, 2016 15:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shanebp/b78240a1c04ae3732c2a2677b7473eac to your computer and use it in GitHub Desktop.
Save shanebp/b78240a1c04ae3732c2a2677b7473eac to your computer and use it in GitHub Desktop.
List a member's groups on the Members Directory
function shanebp_user_groups(){
$group_ids = groups_get_user_groups( bp_get_member_user_id() );
foreach( $group_ids["groups"] as $id ) {
$group = groups_get_group( array( 'group_id' => $id ) );
echo '<a href=' . trailingslashit( bp_get_groups_directory_permalink() . $group->slug . '/' ) . '>' . $group->name . '<a/><br>';
}
}
add_action( 'bp_directory_members_item', 'shanebp_user_groups' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment