Skip to:
Content
Pages
Categories
Search
Top
Bottom

Detecting if user is Moderator and other template tags

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

  • Roger Coathup
    Participant

    @rogercoathup

    Did you look in the documentation on this site before posting?

    Look at BuddyPress template tags in the documentation section.

    [Edit: having told you to look there, the function you actually need is missing. Try bp_is_my_profile()]


    jordashtalon
    Member

    @jordashtalon

    @rogercoathup

    so what does bp_is_my_profile() do? Does it detect if it’s my (the administrators) profile? I also need to detect if it is any moderators profile (I have about 20 moderators).

    I was looking through here: https://codex.buddypress.org/developer-docs/buddypress-template-tags/

    But I can’t find a function that detects whether they are a moderator or not.

    Any ideas?


    Boone Gorges
    Keymaster

    @boonebgorges

    `groups_is_user_mod( $user_id, $group_id )`
    `groups_is_user_admin( $user_id, $group_id )`

    Check out their definitions in bp-groups.php. They check whether the user is a mod/admin of a particular group.

    But that won’t work all that well on a profile page, because a user could be a member of a number of groups, so you won’t have a specific group_id to feed into the function. In what circumstances will the Moderator button appear? If they’re a moderator of *any* groups?


    jordashtalon
    Member

    @jordashtalon

    @boonebgorges

    Yeah I was hoping to try and display that they were a moderator if they were a moderator of Any Group, or i’m thinking have on the profile page say something to the effect of: “Moderator of: x group, y group, z group”

    I just realized on the forum topic page there is a CSS Class added to each Moderators Topic post, so I could add some CSS to the Forum topics to highlight what the moderators are saying.

    to get a list of groups which a member is a moderator/admin of try:

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

    (returns an array with groups and total)


    Jean-Marc
    Participant

    @chefouvi

    @etiviti,
    How does one use the BP_Groups_Member::get_is_admin_of( $user_id )? I mean where do do I put it in order to only list groups that user is admin or mod of.? This is a bit confusing.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Detecting if user is Moderator and other template tags’ is closed to new replies.
Skip to toolbar