WC_API_Authentication::get_user_by_id()
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() WC API Authentication::get user by id code WC 7.7.0
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; }