Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to get group info by id outside of the loop

  • Avatar of ajayver
    ajayver
    Member

    @ajayver

    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)
  • Avatar of ajayver
    ajayver
    Member

    @ajayver

    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…

    Avatar of Virtuali
    Virtuali
    Participant

    @gunju2221

    `bp_get_group_id()`

    or:

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

    Avatar of ajayver
    ajayver
    Member

    @ajayver

    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 :)

    Avatar of drebabels
    drebabels
    Member

    @drebabels

    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 )

    Avatar of ajayver
    ajayver
    Member

    @ajayver

    Thank’s a lot, drebabels!

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

You must be logged in to reply to this topic.