Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BuddyPress, get url (link) of a group using the group id

I'am getting the id of a group using:

$group = groups_get_group( array( 'group_id' => $id) );

But for the life of me I can't figure out how to return the link to the group its self.

I can grab the slug, but some groups are sub groups so I can't just:

echo 'domain/groups/'.$group->slug;

Any help greatly appreciated.

like image 558
john Avatar asked May 28 '15 12:05

john


2 Answers

Did you try:

bp_get_group_permalink( $group );

That will return the href value for the group. To get an html link use:

bp_get_group_link( $group );
like image 154
shanebp Avatar answered Sep 29 '22 22:09

shanebp


For anyone still needing the answer to why bp_get_group_permalink( $group ); doesn't work with just the group id, its because you need to create a Buddypress Group Object. Something like this:

    $group_obj = groups_get_group ( $group_id );
    $href = bp_get_group_permalink( $group_obj );
like image 43
Phyfey Avatar answered Sep 30 '22 00:09

Phyfey