Skip to:
Content
Pages
Categories
Search
Top
Bottom

Display user’s role on the members-loop.php file

  • @cuban100

    Member

    Been trying to get this sniped all day long without success.

    Just trying to display the wordpress user’s role on the member’s loop.

    Did try several different ways but haven’t be able to do so

    it’s there any help on this?

Viewing 3 replies - 1 through 3 (of 3 total)
  • @modemlooper

    Moderator

    Don’t query table, BP and WP has methods to get the info.

    plop this inside the members loop:

    `<?php
    global $members_template;

    $user_id = $members_template->member->id;
    $user = new WP_User($user_id);

    $role = array_keys($user->wp_capabilities,”1″);

    echo ‘User Level: ‘ . $role[0];
    ?>`

    @dan-gaia

    Participant

    Thank You so much….I ended up using this to remove s2member’s ‘free subscriber’ from the member’s list…Lots of Help!

    @4ella

    Participant

    Hi @modemlooper, does your code work yet with the current version of Buddypress?
    I get empty members directory when I put this `<?php
    global $members_template;

    $user_id = $members_template->member->id;
    $user = new WP_User($user_id);

    $role = array_keys($user->wp_capabilities,”1″);

    echo ‘User Level: ‘ . $role[0];
    ?>` into the members-loop.php, btw. does exists similar code for bp-custom.php to do not overwrite files? thanks Daniel

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Display user’s role on the members-loop.php file’ is closed to new replies.
Skip to toolbar