[wp-hackers] current_user_can() and roles ?
Frank Bueltge
frank at bueltge.de
Wed Jan 6 16:38:05 UTC 2010
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?
now i have write a small function for use rolename on this :
function check_role() {
$value = get_option( MY_OPTION );
if ( !isset( $value['role'][0] ) || ( $value['role'][0] != '' ) )
$role = 'level_8';
if ( $value['role'][0] == 'administrator' )
$role = 'level_8';
if ( $value['role'][0] == 'editor' )
$role = 'level_7';
if ( $value['role'][0] == 'author' )
$role = 'level_2';
if ( $value['role'][0] == 'contributor' )
$role = 'level_1';
if ( $value['role'][0] == 'subscriber' )
$role = 'level_0';
if ( current_user_can( $role ) )
return true;
return false;
}
Maybe give it a better solution with WP core?
Thanks for your help to see my probleme and read my bad english.
best wishes
Frank
http://bueltge.de : frank at bueltge.de
http://wpengineer.com : frank at wpengineer.com
More information about the wp-hackers
mailing list