[wp-hackers] User Roles

Jennifer Hodgdon yahgrp at poplarware.com
Mon Mar 19 15:06:02 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...

I believe that as of 2.0, users can be assigned to multiple roles (by 
plugins, if not through the user interface), and I think they may be 
able to be assigned capabilities outside of roles as well. So it might 
not make much sense to ask what the current user's role is.

Assuming you are writing a plugin, the right thing to do (as I 
understand it) is to define a capability for your plugin (or use one 
of the built-in capabilities) and ask whether the current user has 
permission to use that capability with the current_user_can function 
(in wp-includes/capabilities.php).


More information about the wp-hackers mailing list