1. 首页
  2. WordPress 函数手册

is_email_address_unsafe()

is_email_address_unsafe( string $user_email )

根据禁止域列表检查电子邮件地址。
Checks an email address against a list of banned domains.

目录锚点:#说明#参数#返回#源码


说明(Description)

此功能检查wp admin/network上的禁用电子邮件域列表/设置.php. 该检查仅在自我注册时运行;用户创建在wp admin/network/用户.php绕过这张支票。


参数(Parameters)

参数 类型 必填 说明
$user_email (string) 必需 用户注册时提供的电子邮件。

返回(Return)

(bool)当电子邮件地址被禁止时返回true。


源码(Source)

/**
 * 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.
 *
 * @since MU
 *
 * @param string $user_email The email provided by the user at registration.
 * @return bool Returns true when the email address is banned.
 */
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( "
", $banned_names );

	$is_email_address_unsafe = false;

	if ( $banned_names && is_array( $banned_names ) ) {
		$banned_names = array_map( 'strtolower', $banned_names );
		$normalized_email = strtolower( $user_email );

		list( $email_local_part, $email_domain ) = explode( '@', $normalized_email );

		foreach ( $banned_names as $banned_domain ) {
			if ( ! $banned_domain )
				continue;

			if ( $email_domain == $banned_domain ) {
				$is_email_address_unsafe = true;
				break;
			}

			$dotted_domain = ".$banned_domain";
			if ( $dotted_domain === substr( $normalized_email, -strlen( $dotted_domain ) ) ) {
				$is_email_address_unsafe = true;
				break;
			}
		}
	}

	/**
	 * Filter whether an email address is unsafe.
	 *
	 * @since 3.5.0
	 *
	 * @param bool   $is_email_address_unsafe Whether the email address is "unsafe". Default false.
	 * @param string $user_email              User email address.
	 */
	return apply_filters( 'is_email_address_unsafe', $is_email_address_unsafe, $user_email );
}
更新版本 源码位置 使用 被使用
MU (3.0.0) wp-includes/ms-functions.php:397 1 function 3

is_email_address_unsafe() 为WP2原创文章,链接:https://www.wp2.cn/functions/is_email_address_unsafe/

发表评论

您的电子邮箱地址不会被公开。