- Timestamp:
- 03/23/2023 01:52:25 PM (19 months ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/user.php
r55414 r55584 2124 2124 } 2125 2125 2126 // Username must be unique.2127 2126 if ( ! $update && username_exists( $user_login ) ) { 2128 2127 return new WP_Error( 'existing_user_login', __( 'Sorry, that username already exists!' ) ); 2129 }2130 2131 // Username must not match an existing user email.2132 if ( email_exists( $user_login ) ) {2133 return new WP_Error( 'existing_user_email_as_login', __( 'Sorry, that username is not available.' ) );2134 2128 } 2135 2129 … … 3347 3341 } elseif ( username_exists( $sanitized_user_login ) ) { 3348 3342 $errors->add( 'username_exists', __( '<strong>Error:</strong> This username is already registered. Please choose another one.' ) ); 3349 } elseif ( email_exists( $sanitized_user_login ) ) {3350 $errors->add( 'username_exists_as_email', __( '<strong>Error:</strong> This username is not available. Please choose another one.' ) );3351 3343 } else { 3352 3344 /** This filter is documented in wp-includes/user.php */ -
trunk/tests/phpunit/tests/user.php
r55360 r55584 899 899 900 900 /** 901 * @ticket 57394902 */903 public function test_wp_insert_user_should_reject_user_login_that_matches_existing_user_email() {904 $existing_email = get_option( 'admin_email' );905 $user_id = wp_insert_user(906 array(907 'user_login' => $existing_email,908 'user_email' => 'whatever@example.com',909 'user_pass' => 'whatever',910 'user_nicename' => 'whatever',911 )912 );913 914 $this->assertWPError( $user_id );915 $this->assertSame( 'existing_user_email_as_login', $user_id->get_error_code() );916 }917 918 /**919 901 * @ticket 33793 920 902 */
Note: See TracChangeset
for help on using the changeset viewer.