Skip to:
Content
Pages
Categories
Search
Top
Bottom

bp group API function to fetch a group by id outside of group context?

  • Is there a bp group API function to fetch a group by id?

    I want to display the name and avatar of group on a WP page outside of BP. Can I fetch group info by id outside of a group context?

Viewing 2 replies - 1 through 2 (of 2 total)

  • Boone Gorges
    Keymaster

    @boonebgorges

    Try this:
    `$group = new BP_Groups_Group( $group_id );`

    $group will then be an object containing the group name and a few other pieces of info. You’ll need to use bp_core_fetch_avatar() to get the avatar.

    Thanks. I figured it out while waiting, even though your response was immediate ;)

    $group = new BP_Groups_Group( 1, true );
    $avatar = bp_core_fetch_avatar(
    array(
    ‘item_id’ => 1,
    ‘object’ => ‘group’,
    ‘type’ => ‘full’,
    ‘avatar_dir’ => ‘group-avatars’,
    ‘alt’ => ‘Group Avatar’,
    ‘css_id’ => 0,
    ‘class’ => ‘avatar’,
    ‘width’ => false,
    ‘height’ => false
    )
    );

    echo $avatar . “
    “;
    echo ‘slug.’/”>’.$group->name.’
    ‘.$group->description;

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘bp group API function to fetch a group by id outside of group context?’ is closed to new replies.
Skip to toolbar