The question might be simple. Since I need to fix it soon I had to ask.
Currently I am modifying a free plugin. In that I am having the user login string.
How can I get the role for that login?
I’m using WordPress 3.8.
2 Answers
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