Getting a user role from the user login name

You’ll want to use get_user_by(), which will return a WP_USER object which contains roles and capabilities. More info here.

$user = get_user_by( 'login', 'username');

$roles = $user->roles // this will contain an array of the roles the user is in

Leave a Comment