You can get current user role name by following code:

    if(is_user_logged_in()){
        $current_user = wp_get_current_user();
        $role_name = $current_user->roles[0];
        return $role_name;
    }else{
        return NULL;
    }

Use `$role_name` variable to get current user role name.

NOTE: User must have to login to view role name otherwise this code will return `NULL`