WC_Coupon::set_email_restrictions()publicWC 3.0.0

Set email restrictions.

Method of the class: WC_Coupon{}

No Hooks.

Return

null. Nothing (null).

Usage

$WC_Coupon = new WC_Coupon();
$WC_Coupon->set_email_restrictions( $emails );
$emails(array)
List of emails.
Default: array()

Changelog

Since 3.0.0 Introduced.

WC_Coupon::set_email_restrictions() code WC 9.4.2

public function set_email_restrictions( $emails = array() ) {
	$emails = array_filter( array_map( 'sanitize_email', array_map( 'strtolower', (array) $emails ) ) );
	foreach ( $emails as $email ) {
		if ( ! is_email( $email ) ) {
			$this->error( 'coupon_invalid_email_address', __( 'Invalid email address restriction', 'woocommerce' ) );
		}
	}
	$this->set_prop( 'email_restrictions', $emails );
}