WP_REST_Users_Controller::get_item()publicWP 4.7.0

Retrieves a single user.

Method of the class: WP_REST_Users_Controller{}

No Hooks.

Return

WP_REST_Response|WP_Error. Response object on success, or WP_Error object on failure.

Usage

$WP_REST_Users_Controller = new WP_REST_Users_Controller();
$WP_REST_Users_Controller->get_item( $request );
$request(WP_REST_Request) (required)
Full details about the request.

Changelog

Since 4.7.0 Introduced.

WP_REST_Users_Controller::get_item() code WP 6.6.2

public function get_item( $request ) {
	$user = $this->get_user( $request['id'] );
	if ( is_wp_error( $user ) ) {
		return $user;
	}

	$user     = $this->prepare_item_for_response( $user, $request );
	$response = rest_ensure_response( $user );

	return $response;
}