Use 'invalid_username' error code when tripping 'illegal_user_logins'.
This gives us better compatibility with existing errors thrown by `sanitize_user()`, especially in Multisite, where user_login has more restrictions on allowed characters. Props markjaquith. Fixes #27317. Built from https://develop.svn.wordpress.org/trunk@35772 git-svn-id: http://core.svn.wordpress.org/trunk@35736 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
c589ceb880
commit
43d1ab4720
|
@ -146,7 +146,7 @@ function edit_user( $user_id = 0 ) {
|
||||||
$illegal_logins = (array) apply_filters( 'illegal_user_logins', array() );
|
$illegal_logins = (array) apply_filters( 'illegal_user_logins', array() );
|
||||||
|
|
||||||
if ( in_array( strtolower( $user->user_login ), array_map( 'strtolower', $illegal_logins ) ) ) {
|
if ( in_array( strtolower( $user->user_login ), array_map( 'strtolower', $illegal_logins ) ) ) {
|
||||||
$errors->add( 'illegal_user_login', __( '<strong>ERROR</strong>: Sorry, that username is not allowed.' ) );
|
$errors->add( 'invalid_username', __( '<strong>ERROR</strong>: Sorry, that username is not allowed.' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* checking email address */
|
/* checking email address */
|
||||||
|
|
|
@ -1331,7 +1331,7 @@ function wp_insert_user( $userdata ) {
|
||||||
$illegal_logins = (array) apply_filters( 'illegal_user_logins', array() );
|
$illegal_logins = (array) apply_filters( 'illegal_user_logins', array() );
|
||||||
|
|
||||||
if ( in_array( strtolower( $user_login ), array_map( 'strtolower', $illegal_logins ) ) ) {
|
if ( in_array( strtolower( $user_login ), array_map( 'strtolower', $illegal_logins ) ) ) {
|
||||||
return new WP_Error( 'illegal_user_login', __( 'Sorry, that username is not allowed.' ) );
|
return new WP_Error( 'invalid_username', __( 'Sorry, that username is not allowed.' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2124,6 +2124,13 @@ function register_new_user( $user_login, $user_email ) {
|
||||||
$sanitized_user_login = '';
|
$sanitized_user_login = '';
|
||||||
} elseif ( username_exists( $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.' ) );
|
$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_map( 'strtolower', (array) apply_filters( 'illegal_user_logins', array() ) );
|
||||||
|
if ( in_array( strtolower( $sanitized_user_login ), $illegal_user_logins ) ) {
|
||||||
|
$errors->add( 'invalid_username', __( '<strong>ERROR</strong>: Sorry, that username is not allowed.' ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the email address
|
// Check the email address
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.4-RC1-35771';
|
$wp_version = '4.4-RC1-35772';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue