Skip to:
Content
Pages
Categories
Search
Top
Bottom

Query Group Info from Just the ID


  • techguy
    Participant

    @crashutah

    I’m looking for a way to take the group variable that’s passed into the registration page (ie: $referring_groupid = $bp->action_variables[2];) and being able to query for the information for the group with that ID.

    I guess I could use bp_has_groups() and scroll through the list to see if it exists. However, that seems like the hard and “expensive” way to do it. Is there a way to just query for a specific group’s info based on the id for that group? I think that in WP you could use a WP_query or something. Is there something similar that I could use in BP?

Viewing 4 replies - 1 through 4 (of 4 total)
  • What about something like does? You’ll have to dump the var to check what it contains.


    $group = new BP_Groups_Group( $group_id );


    techguy
    Participant

    @crashutah

    Thanks Paul. That works perfect.

    Lots of good information there. Is there a place where it lists all of those objects that can be called like this? I found this function page: https://codex.buddypress.org/developer-docs/functions/ but BP_Groups_Group() wasn’t on that and doesn’t specify any variables that can be passed in.

    Probably not yet. I knew we were after a class/object for Groups, so I’d know it would be in bp-groups/bp-groups-classes.php, found it, then had a look elsewhere in the code to check how it was used.


    techguy
    Participant

    @crashutah

    Good information. Looks like there’s a number of classes available. Like I just saw a BP_Friends_Friendship () one that could be used for friends. Is there any reason not to use these classes?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Query Group Info from Just the ID’ is closed to new replies.
Skip to toolbar