Subject: [PATCH] 57967
---
Index: src/wp-includes/user.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/wp-includes/user.php b/src/wp-includes/user.php
--- a/src/wp-includes/user.php	(revision d0f1816c36e7715c76e663b2459e191003def2bc)
+++ b/src/wp-includes/user.php	(date 1679436241777)
@@ -2129,7 +2129,8 @@
 	}
 
 	// Username must not match an existing user email.
-	if ( email_exists( $user_login ) ) {
+	$existing_user_id = email_exists( $user_login );
+	if ( $existing_user_id && ( ! $update || ( $user_id && $existing_user_id !== $user_id ) ) ) {
 		return new WP_Error( 'existing_user_email_as_login', __( 'Sorry, that username is not available.' ) );
 	}
 
