Its easy to get the currently logged-in user role by using the global variable $current_user. Following function can be used to get the current user's role.
if(!function_exists('custom_get_current_user_role')) {
function custom_get_current_user_role(){
if(is_user_logged_in()) {
global $current_user;
$user_role = $current_user->roles[0];
return $user_role;
}
return FALSE;
}
}
No comments:
Post a Comment