Support » Plugins » Getting a WP user’s role

  • Resolved ninnypants


    I need to retrieve a users role for some functionality in my site, but cannot find a way to get the role.
    I’ve tried get_currentuserinfo() but have had no luck with that. Is there another way to retrieve this information?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Something like…

    <?php if (current_user_can('****_****')){ ?>

    …followed by conditional statements maybe? I’m not sure if that’s on the right track or not (’cause I’m just a hack)!


    list of capabilities and rolls found here

    Works thanks!
    I was hoping for something simpler, but this seems to be the only way.

    Using WP_User class is easier. First, grab the user info:
    $user = new WP_User($ID);

    Now you can grab the wp_capabilities array and do what you want with it.

    E.g. test for a role capability:

    if ($user->wp_capabilities[‘administrator’]==1) {

    E.g. print a list of user’s roles as an array:


    Details on WP_user:

    Yet another method:

    global $current_user;


    if($current_user->user_level == 0){ /* Is user subscriber? */

    *See: User Level to Role Conversion to set appropriate value for user_level.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Getting a WP user’s role’ is closed to new replies.