From daf4acf2bec7324069b1e80071f4a596b8067757 Mon Sep 17 00:00:00 2001 From: Dries Buytaert <dries@buytaert.net> Date: Wed, 21 Jan 2009 14:37:35 +0000 Subject: [PATCH] - Patch #195976 by mcarbone: made error message more accurate and more informative. --- modules/user/user.module | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/user/user.module b/modules/user/user.module index 506c5d28e856..8f8f66746c1a 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')))); + } } } } -- GitLab