Skip to:
Content
Pages
Categories
Search
Top
Bottom

Admin label in buddypress profiles

  • @reinaldudras

    Participant

    Anyone knows how to display custom label like “administrator” in buddypress profile loop for these users who is network administrators?

Viewing 7 replies - 1 through 7 (of 7 total)
  • @henrywright

    Moderator

    Hi @reinaldudras,

    user_can() is the function you need. For example:

    if ( user_can( bp_get_member_user_id(), 'manage_sites' ) )
        echo 'network administrator';

    Note: Untested. There’s a slightly different method of getting the member’s ID depending on the exact context you need. I suspect bp_get_member_user_id() will work.

    Ref: https://codex.wordpress.org/Function_Reference/user_can

    @reinaldudras

    Participant

    Hello @henrywright

    Thank you for your response!

    I read article about this topic, and said that I should put something inside my theme function.php file to show the label every user who have a “super user” role or something.. But unfortunately I forget where I read it.

    Do u know what I need add?

    @henrywright

    Moderator

    I’ve no idea what you might have read but you can accomplish this via hooks. Specifically, the bp_profile_header_meta could be what you need. Try adding this to your theme’s functions.php file:

    function my_output_user_role_function() {
        if ( user_can( bp_get_member_user_id(), 'manage_sites' ) )
            echo 'Role: network administrator';
    }
    add_action( 'bp_profile_header_meta', 'my_output_user_role_function' );

    Note: You can change the text Role: network administrator to whatever you like.

    @reinaldudras

    Participant

    Hi again!

    These pictures https://www.dropbox.com/s/jkkoh09efqvr901/directory.jpg?dl=0 and https://www.dropbox.com/s/hgy054419sgij3t/profile.jpg?dl=0 shows what I need.
    I mean this labels can show in members directory and profile under the nickname/username output (member-loop section) and this label can be displayed only for admins and moderators

    Does it makes sense?:)

    @henrywright

    Moderator

    You’ll need to modify the templates to achieve that.

    @reinaldudras

    Participant

    I see but I dont know exactly what I need to add inside this files.. :/

    @henrywright

    Moderator

    See my first post in this thread. That should do it for you.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Admin label in buddypress profiles’ is closed to new replies.
Skip to toolbar