[wp-hackers] User Roles
Dougal Campbell
dougal at gunters.org
Mon Mar 19 19:09:14 GMT 2007
Andy Staines wrote:
> I'm pretty sure I must have missed the obvious on my trawl through the
> code but can someone tell me the 'correct' way to get the currently
> logged in users 'role'. Don't need the capabilities or levels - just
> the role. The methods I am using seem somewhat long-winded...
> Thanks
> Andy
In wp-admin/users.php, it looks like we do something like this:
$user = new WP_User($id);
$roles = $user->roles; // $roles will be an array
Of course, under the covers, it's querying capabilities, and comparing
them to the list of roles from the '*_user_roles' entry in the options
table.
--
Dougal Campbell <dougal at gunters.org>
http://dougal.gunters.org/
More information about the wp-hackers
mailing list