Test

<?php
global $current_user;
$role = $current_user->roles[0];
$role_name = $role ? wp_roles()->get_names()[ $role ] : '';
echo $role_name;
?>