Tristan .L Tristan .L - 2 years ago 177
PHP Question

Get user role by ID Wordpress

I need to somehow check someones role with only their id.
I have found the

check. But this only works for people that are logged in. How would I check for this if that user isn't the current user? I am using a phone order system but that uses the the admin/specific acount to order for other people.

Thank you

Answer Source

You can't get user role directly. First, you have to get the user_meta_data, and it will return an Object that will contain user roles.



$user_roles=$user_meta->roles; //array of roles the user is part of.
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download