Checks if a given request has access to read a user.
Parameters
$request
WP_REST_Requestrequired- Full details about the request.
Source
$error = new WP_Error(
'rest_user_invalid_id',
__( 'Invalid user ID.' ),
array( 'status' => 404 )
);
if ( (int) $id <= 0 ) {
return $error;
}
$user = get_userdata( (int) $id );
if ( empty( $user ) || ! $user->exists() ) {
return $error;
}
if ( is_multisite() && ! is_user_member_of_blog( $user->ID ) ) {
return $error;
}
return $user;
}
/**
* Checks if a given request has access to read a user.
*
* @since 4.7.0
*
* @param WP_REST_Request $request Full details about the request.
Changelog
Version | Description |
---|---|
4.7.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.