WC_API_Authentication::get_user_by_id()privateWC 2.4.0

Get user by ID

Method of the class: WC_API_Authentication{}

No Hooks.

Return

WP_User.

Usage

// private - for code of main (parent) class only
$result = $this->get_user_by_id( $user_id );
$user_id(int) (required)
-

Changelog

Since 2.4.0 Introduced.

WC_API_Authentication::get_user_by_id() code WC 8.6.1

private function get_user_by_id( $user_id ) {
	$user = get_user_by( 'id', $user_id );

	if ( ! $user ) {
		throw new Exception( __( 'API user is invalid', 'woocommerce' ), 401 );
	}

	return $user;
}