[wp-hackers] current_user_can() and roles ?

Jeremy Clarke jer at simianuprising.com
Wed Jan 6 18:48:23 UTC 2010

On Wed, Jan 6, 2010 at 11:38 AM, Frank Bueltge <frank at bueltge.de> wrote:
> Hello,
> the function current_user_can() has an paramter to give an object or role.
> from the doc: @param string $capability Capability or role name.
> On my plugin it is not possible to ask with a role_name, only with the
> capability or the level_[value]
> Is this correct or is this a error on my mind?

You should check with specific capabilities rather than with levels.
Like edit_posts, edit_options. Then just specify in your plugin docs
what capability users need to do certain things (or give a plugin
setting where the needed capability is defined from a list).

People who have custom roles will be confused by any use of levels,
the level values are deprecated reverse-compatibility for the old
system from before roles and capabilities were added.

Jeremy Clarke | http://jeremyclarke.org
Code and Design | http://globalvoicesonline.org

More information about the wp-hackers mailing list