is_email_address_unsafe

Definition:
function is_email_address_unsafe( $user_email ) {}

Checks an email address against a list of banned domains.
This function checks against the Banned Email Domains list at wp-admin/network/settings.php. The check is only run on self-registrations; user creation at wp-admin/network/users.php bypasses this check.

Parameters

  • string $user_email: The email provided by the user at registration.

Return values

returns:Returns true when the email address is banned.

Source code

function is_email_address_unsafe( $user_email ) {

	$banned_names = get_site_option( 'banned_email_domains' );

	if ($banned_names && !is_array( $banned_names ))

		$banned_names = explode( "\n", $banned_names);



	if ( is_array( $banned_names ) && empty( $banned_names ) == false ) {

		$email_domain = strtolower( substr( $user_email, 1 + strpos( $user_email, '@' ) ) );

		foreach ( (array) $banned_names as $banned_domain ) {

			if ( $banned_domain == '' )

				continue;

			if (

				strstr( $email_domain, $banned_domain ) ||

				(

					strstr( $banned_domain, '/' ) &&

					preg_match( $banned_domain, $email_domain )

				)

			)

			return true;

		}

	}

	return false;

}

2117

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: