Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    Interesting… I thought there’d be a simple function call.

    https://kellenmace.com/get-current-users-role-in-wordpress/

    Moderator bcworkz

    (@bcworkz)

    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.