get user role. parameter id return type string [closed]

You should use WordPress functions to get the user role by user id. Please try code given below:

function user_role_parameter($user_id)
{
    $user_meta = get_userdata($user_id);

    if ( !empty($user_meta) ) {
        $user_roles = $user_meta->roles;
        $user_role="";
        foreach( $user_roles as $role ){
            $user_role .= $role . ', ';
        }
        return $user_role;
    } else {
        return "";
    }
}

error code: 523