Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to get group info by id outside of the loop

  • @ajayver

    Member

    Hello!
    Is there an easy way to show group’s name, permalink and other info using the group’s ID?
    I mean without any loops, just for one group for example?

Viewing 5 replies - 1 through 5 (of 5 total)
  • @ajayver

    Member

    Any Ideas? I want to write a simple plugin that shows the tree of hierarchial groups. I can’t belive that there is no easier way than quering the database…

    @gunju2221

    Participant

    `bp_get_group_id()`

    or:

    `global $bp;
    $bp->groups->current_group->id;`

    @ajayver

    Member

    Thanks, but did you read my question? :)
    I have all the Id’s, I want to access their names and permalinks to show in the list.
    For example, I need to show links to groups 1, 12, 42 and 99, in the sidebar, I don’t need current group Id for that :)

    @drebabels

    Member

    I needed to do this recently too… this is the technique I used:

    $group = groups_get_group( array( ‘group_id’ => $group_id ) );

    Found on http://bluemandala.com/buddypress-plugin/127/buddypress-get-group-details-from-group_id/

    So in order to get the link to your groups try something like this

    global $bp;
    $group = groups_get_group( array( ‘group_id’ => $group_id ) );
    home_url( $bp->groups->slug . ‘/’ . $group -> slug )

    @ajayver

    Member

    Thank’s a lot, drebabels!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to get group info by id outside of the loop’ is closed to new replies.
Skip to toolbar