WC_Customer_Data_Store::get_user_ids_for_billing_email()publicWC 1.0

Get all user ids who have billing_email set to any of the email passed in array.

Method of the class: WC_Customer_Data_Store{}

No Hooks.

Return

Array.

Usage

$WC_Customer_Data_Store = new WC_Customer_Data_Store();
$WC_Customer_Data_Store->get_user_ids_for_billing_email( $emails );
$emails(array) (required)
List of emails to check against.

WC_Customer_Data_Store::get_user_ids_for_billing_email() code WC 9.4.2

public function get_user_ids_for_billing_email( $emails ) {
	$emails      = array_unique( array_map( 'strtolower', array_map( 'sanitize_email', $emails ) ) );
	$users_query = new WP_User_Query(
		array(
			'fields'     => 'ID',
			'meta_query' => array(
				array(
					'key'     => 'billing_email',
					'value'   => $emails,
					'compare' => 'IN',
				),
			),
		)
	);
	return array_unique( $users_query->get_results() );
}