Automattic\WooCommerce\Admin\API\Reports\Customers
DataStore::is_valid_customer()
Check if a user ID is a valid customer or other user role with past orders.
Method of the class: DataStore{}
Hooks from the method
Return
true|false
.
Usage
$result = DataStore::is_valid_customer( $user_id );
- $user_id(int) (required)
- User ID.
DataStore::is_valid_customer() DataStore::is valid customer code WC 9.3.3
protected static function is_valid_customer( $user_id ) { $user = new \WP_User( $user_id ); if ( (int) $user_id !== $user->ID ) { return false; } /** * Filter the customer roles, used to check if the user is a customer. * * @param array List of customer roles. * @since 4.0.0 */ $customer_roles = (array) apply_filters( 'woocommerce_analytics_customer_roles', array( 'customer' ) ); if ( empty( $user->roles ) || empty( array_intersect( $user->roles, $customer_roles ) ) ) { return false; } return true; }