From 05666ec7bc5d4bf94a63ceb3108f8eba989b15b1 Mon Sep 17 00:00:00 2001 From: ryan Date: Fri, 17 Apr 2009 18:43:40 +0000 Subject: [PATCH] Enforce unique email addresses. Props Denis-de-Bernardy. fixes #9563 git-svn-id: http://svn.automattic.com/wordpress/trunk@10990 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- 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;