$user_email =
apply_filters( 'user_registration_email',
$user_email );
// Check the username.
if ( '' ===
$sanitized_user_login ) { $errors->
add( 'empty_username',
__( '<strong>Error:</strong> Please enter a username.'
) );
} elseif ( !
validate_username( $user_login ) ) { $errors->
add( 'invalid_username',
__( '<strong>Error:</strong> This username is invalid because it uses illegal characters. Please enter a valid username.'
) );
$sanitized_user_login = '';
} elseif ( username_exists( $sanitized_user_login ) ) { $errors->
add( 'username_exists',
__( '<strong>Error:</strong> This username is already registered. Please choose another one.'
) );
} else { /** This filter is documented in wp-includes/user.php */
$illegal_user_logins =
(array) apply_filters( 'illegal_user_logins', array
() );
if ( in_array( strtolower( $sanitized_user_login ),
array_map( 'strtolower',
$illegal_user_logins ), true
) ) { $errors->
add( 'invalid_username',
__( '<strong>Error:</strong> Sorry, that username is not allowed.'
) );
} }