1

I'm trying to edit a user, but I keep getting the following error:

The email address [their email] is already taken.

I'm not editing their email. In fact, I could open the edit page, just hit Save without changing anything, and I would still get the error.

Why am I getting this error message?

4
  • 1
    It appears that email is already in the database on another row. Could it be you've accidentally created or imported your users twice? If you do not use the forms but modify users programmatically, it can appear that the same email is added to the database twice (the form validation does not run in those cases). Then later when you try to edit one such user, it cannot save because that account should not have existed in the first place. Double check that you have no modules that can create accounts from email addresses (eg. Drupal commerce) and check your database users table. Commented May 4, 2016 at 20:56
  • @Neograph734 Boy do I feel dumb. I forgot I had imported users for testing on this dev version. One of those happened to share my admin email.
    – Jack
    Commented May 4, 2016 at 21:00
  • I've added a slightly more complete answer. Glad to be able to help you :) Commented May 4, 2016 at 21:16
  • You can use the module at github.com/Fonata/shared_email - thanks to @burgdawg!
    – Gogowitsch
    Commented Nov 9, 2017 at 10:47

2 Answers 2

3

It appears that email is already in the database on another row. This can have many causes; importing users twice, creating accounts in a custom module without proper checking if the email address is available, etc.

If you do not use the account edit forms, but modify users programmatically, it can appear that the same email is added to the database twice (the form validation does not run in those cases). Then later when you try to edit one such user, it cannot save because that account should not have existed in the first place. This measure is there so users cannot sign up with the same email twice, but since the user creation and edit form are in fact the same form (and as such have the same validation), it can happen during the save of a user as well.

Double check that you have no modules that can create accounts from email addresses (eg. Drupal commerce) and check your database users table to identify the duplicate account.

0

I got this same error because an external integration was creating user accounts with duplicate email addresses. The solution for me was to use drush to add the role:

drush urol "role" --name=username

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.