is_email_address_unsafe
apply_filters( ‘is_email_address_unsafe’, bool $is_email_address_unsafe , string $user_email )
筛选挂钩:筛选电子邮件地址是否不安全。
Filter Hook: Filters whether an email address is unsafe.
参数(Parameters)
参数 | 类型 | 说明 |
---|---|---|
$is_email_address_unsafe | (bool) | 电子邮件地址是否“不安全”。默认为false。 |
$user_email | (string) | 用户电子邮件地址。 |
源码(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 ); }
更新版本 | 源码位置 | 使用 | 被使用 |
---|---|---|---|
3.5.0 | wp-includes/ms-functions.php:437 | 1 | 0 |
is_email_address_unsafe 为WP2原创文章,链接:https://www.wp2.cn/hook/is_email_address_unsafe-2/