Created
February 22, 2010 05:11
-
-
Save Lizdo/310818 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function elbe_current_user_can($capability, $current_user) { | |
//replace wp2_ with your database prefix -.- | |
$roles = get_option('wp2_user_roles'); | |
$user_roles = $current_user->wp_capabilities; | |
if ($user_roles == null) | |
return false; | |
$user_roles = array_keys($user_roles, true); | |
$role = $user_roles[0]; | |
$capabilities = $roles[$role]['capabilities']; | |
if ( in_array( $capability, array_keys( $capabilities, true) ) ) { | |
return true; | |
} | |
} | |
//... | |
//in theme logic somewhere | |
if (elbe_current_user_can('discount',$current_user)) | |
//do something | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment