Skip to:
Content
Pages
Categories
Search
Top
Bottom

Checking if Member is also a Group Admin


  • Jonathan
    Member

    @hostprofile

    I’m trying to create a conditional statement that checks to see if a member is a group administrator and if they are, then output a few lines of code on their profile. If they’re not a group administrator, nothing should show.

    The problem I’m having is that there’s not too much documentation on some of the conditionals, so I’m not completely sure which, if any, can be used to solve this.

    Basically when a visitor or member (logged in or not) visits the profile of another member who is also a group administrator, the code should show.

    Any help is greatly appreciated!

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

  • rich
    Member

    @etivite

    if you have the group_id
    `
    check_is_admin( $user_id, $group_id )
    check_is_mod( $user_id, $group_id )
    `

    or
    `
    BP_Groups_Member::get_is_mod_of( $user_id )
    BP_Groups_Member::get_is_admin_of( $user_id )
    `

    which returns an array with number of groups & the groups


    Jonathan
    Member

    @hostprofile

    Thanks @etivite

    What if all I need to do is a check to see if the member is a group admin, is there a better way to do just that? I essentially just need to know if the conditional is true or false. If the member is an admin, we’ll run the code, if they aren’t, then nothing is ran.

    Edit: Forgot to add that we don’t have the Group ID to use on-hand. We are running this check in the footer template file, but it’s only being ran on the profile page(s).


    rich
    Member

    @etivite

    the last 2 are the only ones i’m aware of – but you would need to check if the returned ‘groups’ array is not empty. Have a look at the function located in bp-groups-classes.php – in fact it might be easier to create your own sql query and check for _admin & _mod


    Jonathan
    Member

    @hostprofile

    Thanks again @etivite indeed creating a new MySQL Query was a better option than trying to loop through the array and extract the data. A simple get_var query allowed us to pull the first primary group that the member was an administrator of and that did the trick.

    I appreciate the help!


    8608035
    Inactive

    Recognition is the greatest motivator!


    exocdesneak
    Member

    @exocdesneak

    Formal education will make you a living. Self-education will make you a fortune

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Checking if Member is also a Group Admin’ is closed to new replies.
Skip to toolbar