You can get current user role name(translatable name but not slug) by following function, you just need to pass a parameter current user role slug nameas a parameter:
function wp_get_current_user_translatable_role_name( $current_user_role_slug = '' ) {
$role_name = '';
if ( ! function_exists( 'get_editable_roles' ) ) {
require_once ABSPATH . 'wp-admin/includes/user.php';
}
// Please note that translate_user_role doesn't work in the front-end currently.
load_textdomain( 'default', WP_LANG_DIR . '/admin-' . get_locale() . '.mo' );
$editable_roles = array_reverse( get_editable_roles() );
foreach ( $editable_roles as $role => $details ) {
$name = translate_user_role( $details['name'] );
// preselect specified role
if ( $current_user_role_slug == $role ) {
$role_name = $name;
}
}
echo $role_name ;
}
Now, get current user role slug name by following code:
$user_meta = get_userdata(get_current_user_id());
$current_user_role_slug = $user_meta->roles[0];
Use wp_get_current_user_translatable_role_name( $current_user_role_slug );
function to get current user role name(translatable name but not slug).
NOTE: User must have to login to view role name.