wpcf7_is_email_in_domain()CF7 1.0

Checks whether an email address belongs to a domain.

Хуков нет.

Возвращает

true|false. True if all of the email addresses belong to the domain, false if not.

Использование

wpcf7_is_email_in_domain( $email, $domain );
$email(строка) (обязательный)
A mailbox or a comma-separated list of mailboxes.
$domain(строка) (обязательный)
Internet domain name.

Код wpcf7_is_email_in_domain() CF7 5.6.4

function wpcf7_is_email_in_domain( $email, $domain ) {
	$email_list = wpcf7_is_mailbox_list( $email );

	if ( false === $email_list ) {
		return false;
	}

	$domain = strtolower( $domain );

	foreach ( $email_list as $email ) {
		$email_domain = substr( $email, strrpos( $email, '@' ) + 1 );
		$email_domain = strtolower( $email_domain );
		$domain_parts = explode( '.', $domain );

		do {
			$site_domain = implode( '.', $domain_parts );

			if ( $site_domain == $email_domain ) {
				continue 2;
			}

			array_shift( $domain_parts );
		} while ( $domain_parts );

		return false;
	}

	return true;
}