diff --git a/src/wp-includes/user.php b/src/wp-includes/user.php
index ca4b3d03fdb..7efdec0dd2b 100644
a
|
b
|
function wp_insert_user( $userdata ) { |
2112 | 2112 | return new WP_Error( 'user_login_too_long', __( 'Username may not be longer than 60 characters.' ) ); |
2113 | 2113 | } |
2114 | 2114 | |
| 2115 | // Username must be unique. |
2115 | 2116 | if ( ! $update && username_exists( $user_login ) ) { |
2116 | 2117 | return new WP_Error( 'existing_user_login', __( 'Sorry, that username already exists!' ) ); |
2117 | 2118 | } |
2118 | 2119 | |
| 2120 | // Username must not exist as an existing email. |
| 2121 | if ( email_exists( $user_login ) ) { |
| 2122 | return new WP_Error( 'existing_user_login_as_email', __( 'Sorry, that username is not available.' ) ); |
| 2123 | } |
| 2124 | |
2119 | 2125 | /** |
2120 | 2126 | * Filters the list of disallowed usernames. |
2121 | 2127 | * |
… |
… |
function register_new_user( $user_login, $user_email ) { |
3329 | 3335 | $sanitized_user_login = ''; |
3330 | 3336 | } elseif ( username_exists( $sanitized_user_login ) ) { |
3331 | 3337 | $errors->add( 'username_exists', __( '<strong>Error:</strong> This username is already registered. Please choose another one.' ) ); |
3332 | | |
| 3338 | } elseif ( email_exists( $sanitized_user_login ) ) { |
| 3339 | $errors->add( 'username_exists_as_email', __( '<strong>Error:</strong> This username is not available. Please choose another one.' ) ); |
3333 | 3340 | } else { |
3334 | 3341 | /** This filter is documented in wp-includes/user.php */ |
3335 | 3342 | $illegal_user_logins = (array) apply_filters( 'illegal_user_logins', array() ); |