Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Talk:Function Reference/current user can

Role Names Case Sensitive

Roles are given in title case on Roles_and_Capabilities, but current_user_can('Administrator') will fail. (The correct call is current_user_can('administrator').) Should it be made clear, either on this page or on Roles_and_Capabilities, that the role name must be lowercase?


I think I'll add a note here that the capabilities and roles are case sensitive, but roles should not be passed to this function as this is not guaranteed to work correctly (see #22624). There is a note about this in the notes section. The Roles_and_Capabilities page should probably be checked over to see that it is using proper case and isn't passing roles to this function. I'll do that if I get a chance, and leave a note back here.
Jdgrimes 19:56, 19 September 2013 (UTC)

It looks like the Roles_and_Capabilities page is fixed.
Jdgrimes 20:20, 22 September 2013 (UTC)

warn devs about using function before init

should have the same warning as http://codex.wordpress.org/Function_Reference/wp_get_current_user Use the init or any subsequent action to call this function. Calling it outside of an action can lead to troubles. See #14024 for details.

since this function calls that function.