Created
July 22, 2016 15:49
-
-
Save shanebp/b78240a1c04ae3732c2a2677b7473eac to your computer and use it in GitHub Desktop.
List a member's groups on the Members Directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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