Support » Plugins » display user role on profile page

  • Hello,

    On my blog I am creating a directory using “members list”, I also have role manager installed, and I have created a author.php page. I would like to display on the profile page:

    Your role is: <user_role>

    I was wondering if anyone know of a way that I can display the current role, either one of the default roles or ‘role manager’ roles on the profile page.

    Thank you, and I appreciate your help,

Viewing 5 replies - 1 through 5 (of 5 total)
  • I use this snippet in my BNS Support plugin to show the current user’s role which may accomplish what you are looking for:

    $user_roles = $current_user->roles;
    $user_role = array_shift($user_roles);
    echo '<strong>Current User Role</strong>: ' . $user_role;

    It will only show the first role if the user has more than one assigned to them.

    This worked great, but I was wondering if you know how I can add this to my members list directory. I can display the wp_user_level in the list, but for some reason I can’t display the wp_capabilities.

    Do you know how this can be done?



    I would suggest looking at this page in the codex:

    How to make the first letter capital of user role?

    For example

    $user_roles = $current_user->roles;
    $user_role = array_shift($user_roles);
    if ($user_role == 'administrator') {
    echo 'Administrator';
    } elseif ($user_role == 'editor') {
    echo 'Editor';
    } elseif ($user_role == 'author') {
    echo 'Author';
    } elseif ($user_role == 'contributor') {
    echo 'Contributor';
    } elseif ($user_role == 'subscriber') {
    echo 'Subscriber';
    } else {
    echo '<strong>' . $user_role . '</strong>';
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘display user role on profile page’ is closed to new replies.