Something like…
<?php if (current_user_can('****_****')){ ?>
…followed by conditional statements maybe? I’m not sure if that’s on the right track or not (’cause I’m just a hack)!
🙂
list of capabilities and rolls found here
Works thanks!
I was hoping for something simpler, but this seems to be the only way.
Using WP_User class is easier. First, grab the user info:
$ID=”2″;
$user = new WP_User($ID);
Now you can grab the wp_capabilities array and do what you want with it.
E.g. test for a role capability:
if ($user->wp_capabilities[‘administrator’]==1) {
}
E.g. print a list of user’s roles as an array:
print_r(array_keys($user->wp_capabilities,”1″));
Details on WP_user:
http://core.trac.ww.wp.xz.cn/browser/trunk/wp-includes/capabilities.php
Yet another method:
global $current_user;
get_currentuserinfo();
if($current_user->user_level == 0){ /* Is user subscriber? */
}
*See: User Level to Role Conversion to set appropriate value for user_level.