0

I'm creating a page in my wordpress site, with a list of the users and need to get the title of their role with php. But, every thing I tried failed. Anyone who can help please.

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399
  • Can you be more specific? What exactly have you tried and what problems did you run into while trying. – Kevin May 23 '16 at 08:22

1 Answers1

6

The function that returns the current user roles :

function display_user_roles(){
    $user_id = get_current_user_id();
    $user_info = get_userdata( $user_id );
    $user_roles = implode(', ', $user_info->roles);
    return $user_roles;
}

To use it in your code:

<?php echo display_user_roles(); ?>
LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399