Title: retrieve a user role from database
Last modified: December 14, 2019

---

# retrieve a user role from database

 *  [AlterBlitz](https://wordpress.org/support/users/alterblitz/)
 * (@alterblitz)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/retrieve-a-user-role-from-database/)
 * How do i retrieve a user’s role from database?

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Moderator [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * (@sterndata)
 * Volunteer Forum Moderator
 * [6 years, 5 months ago](https://wordpress.org/support/topic/retrieve-a-user-role-from-database/#post-12238301)
 * Interesting… I thought there’d be a simple function call.
 * [https://kellenmace.com/get-current-users-role-in-wordpress/](https://kellenmace.com/get-current-users-role-in-wordpress/)
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/retrieve-a-user-role-from-database/#post-12239429)
 * Not a direct function call, but the example Steve linked to can be boiled down
   to
    `get_userdata( $user_id )->roles[0]` provided the user’s ID is assigned to
   $user_id. It’s conceivable a user is assigned more than one role by plugin action.
   The above code returns only the first role, the rest are listed in the `roles`
   property as an indexed array. `roles[1], roles[2]` etc. when so assigned.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘retrieve a user role from database’ is closed to new replies.

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 2 replies
 * 3 participants
 * Last reply from: [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * Last activity: [6 years, 5 months ago](https://wordpress.org/support/topic/retrieve-a-user-role-from-database/#post-12239429)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
