I use this code in functions.php to display user role in woocommerce My-Account page (Welcome user...etc.):
function get_user_role() {
global $current_user;
$user_roles = $current_user->roles;
$user_role = array_shift($user_roles);
return $user_role;
}
But it displays only user role ID, without name. How can this code be modified to display USER ROLE NAME instead?
Thanx in advance.
Try this. It returns the translated role name of the current user.