Skip to:
Content
Pages
Categories
Search
Top
Bottom

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

  • 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 4 replies - 1 through 4 (of 4 total)
  • Avatar of shanebpdev
    shanebp
    Participant

    @shanebp

    edit: thanks modemlooper – much better approach

    Avatar of @modemlooper
    @modemlooper
    Moderator

    @modemlooper

    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];
    ?>`

    Avatar of Dan Beil
    Dan Beil
    Participant

    @dan-gaia

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

    Avatar of 4ella
    4ella
    Participant

    @4ella

    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 4 replies - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.