add_action( 'wp_head', 'njengah_get_current_user_role');
function njengah_get_current_user_role() {
if( is_user_logged_in() ) { // check if there is a logged in user
$user = wp_get_current_user(); // getting & setting the current user
$roles = ( array ) $user->roles; // obtaining the role
return $roles; // return the role for the current user
} else {
return array(); // if there is no logged in user return empty array
}
}