diff --git a/modules/user/user.module b/modules/user/user.module index 506c5d28e85681b872ca693c96b5f5c8122d5154..8f8f66746c1acbdd8675fa230b138fad30d07a30 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -749,12 +749,18 @@ function user_user_validate(&$edit, &$account, $category = NULL) { } } - // Validate the e-mail address: + // Validate the e-mail address, and check if it is taken by an existing user. if ($error = user_validate_mail($edit['mail'])) { form_set_error('mail', $error); } elseif (db_result(db_query("SELECT COUNT(*) FROM {users} WHERE uid != %d AND LOWER(mail) = LOWER('%s')", $uid, $edit['mail'])) > 0) { - form_set_error('mail', t('The e-mail address %email is already registered. <a href="@password">Have you forgotten your password?</a>', array('%email' => $edit['mail'], '@password' => url('user/password')))); + // Format error message dependent on whether the user is logged in or not. + if ($GLOBALS['user']->uid) { + form_set_error('mail', t('The e-mail address %email is already taken.', array('%email' => $edit['mail']))); + } + else { + form_set_error('mail', t('The e-mail address %email is already registered. <a href="@password">Have you forgotten your password?</a>', array('%email' => $edit['mail'], '@password' => url('user/password')))); + } } } }