From aacf7f3f4d8882098031400d33db8bf6305898a1 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Fri, 17 Apr 2009 18:43:40 +0000 Subject: [PATCH] Enforce unique email addresses. Props Denis-de-Bernardy. fixes #9563 git-svn-id: https://develop.svn.wordpress.org/trunk@10990 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/includes/user.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/wp-admin/includes/user.php b/wp-admin/includes/user.php index 1f04875f6c..e54a1beaf1 100644 --- a/wp-admin/includes/user.php +++ b/wp-admin/includes/user.php @@ -167,11 +167,12 @@ function edit_user( $user_id = 0 ) { /* checking e-mail address */ if ( empty ( $user->user_email ) ) { - $errors->add( 'user_email', __( 'ERROR: Please enter an e-mail address.' ), array( 'form-field' => 'email' ) ); - } else - if (!is_email( $user->user_email ) ) { - $errors->add( 'user_email', __( "ERROR: The e-mail address isn't correct." ), array( 'form-field' => 'email' ) ); - } + $errors->add( 'empty_email', __( 'ERROR: Please enter an e-mail address.' ), array( 'form-field' => 'email' ) ); + } elseif (!is_email( $user->user_email ) ) { + $errors->add( 'invalid_email', __( "ERROR: The e-mail address isn't correct." ), array( 'form-field' => 'email' ) ); + } elseif ( ( $owner_id = email_exists($user->user_email) ) && $owner_id != $user->ID ) { + $errors->add( 'email_exists', __('ERROR: This email is already registered, please choose another one.'), array( 'form-field' => 'email' ) ); + } if ( $errors->get_error_codes() ) return $errors;