Skip to content

Commit 47e7e51

Browse files
committed
Fix error messages for invalid usernames to use consistent terminology
1 parent acebfd0 commit 47e7e51

4 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/wp-admin/includes/user.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ function edit_user( $user_id = 0 ) {
188188
}
189189

190190
if ( ! $update && isset( $_POST['user_login'] ) && ! validate_username( $_POST['user_login'] ) ) {
191-
$errors->add( 'user_login', __( '<strong>Error:</strong> This username is invalid because it uses illegal characters. Please enter a valid username.' ) );
191+
$errors->add( 'user_login', __( '<strong>Error:</strong> This username is invalid because it uses unallowed characters. Please enter a valid username.' ) );
192192
}
193193

194194
if ( ! $update && username_exists( $user->user_login ) ) {

src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1322,7 +1322,7 @@ public function check_username( $value, $request, $param ) {
13221322
if ( ! validate_username( $username ) ) {
13231323
return new WP_Error(
13241324
'rest_user_invalid_username',
1325-
__( 'This username is invalid because it uses illegal characters. Please enter a valid username.' ),
1325+
__( 'This username is invalid because it uses unallowed characters. Please enter a valid username.' ),
13261326
array( 'status' => 400 )
13271327
);
13281328
}

src/wp-includes/user.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3544,7 +3544,7 @@ function register_new_user( $user_login, $user_email ) {
35443544
if ( '' === $sanitized_user_login ) {
35453545
$errors->add( 'empty_username', __( '<strong>Error:</strong> Please enter a username.' ) );
35463546
} elseif ( ! validate_username( $user_login ) ) {
3547-
$errors->add( 'invalid_username', __( '<strong>Error:</strong> This username is invalid because it uses illegal characters. Please enter a valid username.' ) );
3547+
$errors->add( 'invalid_username', __( '<strong>Error:</strong> This username is invalid because it uses unallowed characters. Please enter a valid username.' ) );
35483548
$sanitized_user_login = '';
35493549
} elseif ( username_exists( $sanitized_user_login ) ) {
35503550
$errors->add( 'username_exists', __( '<strong>Error:</strong> This username is already registered. Please choose another one.' ) );

tests/phpunit/tests/rest-api/rest-users-controller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1416,7 +1416,7 @@ public function test_create_item_invalid_username() {
14161416
$this->assertIsArray( $data['data']['params'] );
14171417
$errors = $data['data']['params'];
14181418
$this->assertIsString( $errors['username'] );
1419-
$this->assertSame( 'This username is invalid because it uses illegal characters. Please enter a valid username.', $errors['username'] );
1419+
$this->assertSame( 'This username is invalid because it uses unallowed characters. Please enter a valid username.', $errors['username'] );
14201420
}
14211421
}
14221422

0 commit comments

Comments
 (0)