Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: illegal_user_logins

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

This hook occurs 2 times in this file.

Line Code
1792      }
1793
1794      /**
1795       * Filters the list of disallowed usernames.
1796       *
1797       * @since 4.4.0
1798       *
1799       * @param array $usernames Array of disallowed usernames.
1800       */
1801      $illegal_logins = (array) apply_filters( 'illegal_user_logins', array() );
1802
1803      if ( in_array( strtolower( $user_login ), array_map( 'strtolower', $illegal_logins ), true ) ) {
1804           return new WP_Error( 'invalid_username', __( 'Sorry, that username is not allowed.' ) );
1805      }
1806
1807      /*
1808       * If a nicename is provided, remove unsafe user characters before using it.
1809       * Otherwise build a nicename from the user_login.
1810       */
 
Line Code
2714           $errors->add( 'empty_username', __( '<strong>Error</strong>: Please enter a username.' ) );
2715      } elseif ( ! validate_username( $user_login ) ) {
2716           $errors->add( 'invalid_username', __( '<strong>Error</strong>: This username is invalid because it uses illegal characters. Please enter a valid username.' ) );
2717           $sanitized_user_login = '';
2718      } elseif ( username_exists( $sanitized_user_login ) ) {
2719           $errors->add( 'username_exists', __( '<strong>Error</strong>: This username is already registered. Please choose another one.' ) );
2720
2721      } else {
2722           /** This filter is documented in wp-includes/user.php */
2723           $illegal_user_logins = (array) apply_filters( 'illegal_user_logins', array() );
2724           if ( in_array( strtolower( $sanitized_user_login ), array_map( 'strtolower', $illegal_user_logins ), true ) ) {
2725                $errors->add( 'invalid_username', __( '<strong>Error</strong>: Sorry, that username is not allowed.' ) );
2726           }
2727      }
2728
2729      // Check the email address.
2730      if ( '' === $user_email ) {
2731           $errors->add( 'empty_email', __( '<strong>Error</strong>: Please type your email address.' ) );
2732      } elseif ( ! is_email( $user_email ) ) {