• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
WordPress core a2z

WordPress core a2z

WordPress core only

  • Home
  • Plugins
  • Blocks
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / is_email_address_unsafe() – Checks an email address against a list of banned domains.

You appear to be a bot. Output may be restricted

Description

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.

Usage

$bool = is_email_address_unsafe( $user_email );

Parameters

$user_email
( string ) required – The email provided by the user at registration.

Returns

bool True when the email address is banned, false otherwise.

Source

File name: wordpress/wp-includes/ms-functions.php
Lines:

1 to 42 of 42
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 );
  }

  $is_email_address_unsafe = false;

  if ( $banned_names && is_array( $banned_names ) && false !== strpos( $user_email, '@', 1 ) ) {
    $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 ( substr( $normalized_email, -strlen( $dotted_domain ) ) === $dotted_domain ) {
        $is_email_address_unsafe = true;
        break;
      }
    }
  }

  
/**
 * Filters 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 );
}
 

 View on GitHub View on Trac

Published: 25th November 2019 | Last updated: 2nd April 2020

Primary Sidebar

Information

Function name: is_email_address_unsafe
Plugin ref: WordPress
Version: 5.6
Sourcefile: wp-includes/ms-functions.php
File ref: wp-includes/ms-functions.php
Deprecated?: No
API Letters: A,E,I,U

Footer

WP-a2z
WordPress core a2z
WordPress core only
WordPress 5.6
WordPress a2z
WordPress core a2z
Genesis Theme Framework a2z
Jetpack a2z
WordPress develop tests
Easy Digital Downloads a2z
WooCommerce a2z
Yoast SEO a2z
WordPress Blocks

Site:  core.wp-a2z.org
© Copyright WP-a2z 2014-2021. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins

  • Home
  • Blog
  • Sitemap
  • Sites