WC_API_Customers::get_customer_by_email( string $email, array $fields = null )
Get the customer for the given email
Description Description
Parameters Parameters
-
(Required) the customer email
- $fields
-
(Optional)
Default value: null
Return Return
(array|WP_Error)
Source Source
File: includes/legacy/api/v2/class-wc-api-customers.php
public function get_customer_by_email( $email, $fields = null ) { try { if ( is_email( $email ) ) { $customer = get_user_by( 'email', $email ); if ( ! is_object( $customer ) ) { throw new WC_API_Exception( 'woocommerce_api_invalid_customer_email', __( 'Invalid customer email', 'woocommerce' ), 404 ); } } else { throw new WC_API_Exception( 'woocommerce_api_invalid_customer_email', __( 'Invalid customer email', 'woocommerce' ), 404 ); } return $this->get_customer( $customer->ID, $fields ); } catch ( WC_API_Exception $e ) { return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); } }
Changelog Changelog
Version | Description |
---|---|
2.1 | Introduced. |