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
1571      }
1572
1573      /**
1574       * Filters the list of blacklisted usernames.
1575       *
1576       * @since 4.4.0
1577       *
1578       * @param array $usernames Array of blacklisted usernames.
1579       */
1580      $illegal_logins = (array) apply_filters( 'illegal_user_logins', array() );
1581
1582      if ( in_array( strtolower( $user_login ), array_map( 'strtolower', $illegal_logins ) ) ) {
1583           return new WP_Error( 'invalid_username', __( 'Sorry, that username is not allowed.' ) );
1584      }
1585
1586      /*
1587       * If a nicename is provided, remove unsafe user characters before using it.
1588       * Otherwise build a nicename from the user_login.
1589       */
 
Line Code
2491           $errors->add( 'empty_username', __( '<strong>ERROR</strong>: Please enter a username.' ) );
2492      } elseif ( ! validate_username( $user_login ) ) {
2493           $errors->add( 'invalid_username', __( '<strong>ERROR</strong>: This username is invalid because it uses illegal characters. Please enter a valid username.' ) );
2494           $sanitized_user_login = '';
2495      } elseif ( username_exists( $sanitized_user_login ) ) {
2496           $errors->add( 'username_exists', __( '<strong>ERROR</strong>: This username is already registered. Please choose another one.' ) );
2497
2498      } else {
2499           /** This filter is documented in wp-includes/user.php */
2500           $illegal_user_logins = (array) apply_filters( 'illegal_user_logins', array() );
2501           if ( in_array( strtolower( $sanitized_user_login ), array_map( 'strtolower', $illegal_user_logins ) ) ) {
2502                $errors->add( 'invalid_username', __( '<strong>ERROR</strong>: Sorry, that username is not allowed.' ) );
2503           }
2504      }
2505
2506      // Check the email address
2507      if ( $user_email == '' ) {
2508           $errors->add( 'empty_email', __( '<strong>ERROR</strong>: Please type your email address.' ) );
2509      } elseif ( ! is_email( $user_email ) ) {