Change user's email without verification

Maybe I’m missing something obvious, but I cannot find it. As an admin, can I change someone’s email address without them having to verify it?

Off-hand, I’d guess something like this would work:

cd /var/discourse
./launcher enter app
rails c
User.find_by(email: "chowder@mmmm.fooo").update(email: "bisque@soup.mmmm")

That’s console access, obviously.


I vaguely recall another topic here about this exact situation; try some searches.

1 Like

Try this, the verification mail goes out, but they don’t have to respond to it:

Too late for me to edit that now, but it should be deactivate, change, reactivate iirc.


No problem I made it a wiki.


I am a new discourse user and I ran into the same issue. When I try the same approach (deactivate the user, update the email address, and then activate the user) it sending an email to confirm and it is only updating the email address after clicking the confirm email link. Is there a way to avoid this? I am using the API to do all the three actions.

There has been a change in the way emails are stored in the database.

The following commands should work:

cd /var/discourse
sudo ./launcher enter app
rails c

UserEmail.find_by(email: "").update(email: "")

This will work fine but I am trying to do this via API as I will have to update multiple email addresses on a daily basis. Is it possible to do this via API?


Massive Necromancy, yes, but I’m experiencing a similar issue and since the search took me here it may be relevant to update the commands based on this experience.

My situation is as follows:

  • Some of my users tried to change their main e-mail.

  • They claim it didn’t work. That they received an e-mail to confirm but when clicking on the link it always gives an “Expired/Doesn’t Work” message.

  • I go as an Admin to change said e-mail, do it by editing their profile.

  • Now the main e-mail is “waiting confirmation/verification”.

  • The users don’t receive any confirmation e-mail.

  • No matter how many times I press the “resend validation/confirmation e-mail” option on their profile, it doesn’t send (checked on the Admin/E-mail section, no outgoing e-mail for that. Ironically if I click to send them the “reset password e-mail” that one does send).

Thing is, if any of those users cleans cookies/etc they won’t be able to access their account again (actually happening right now). So I tried this:

But I’m getting NoMethodError: undefined method `update' for nil:NilClass. So maybe the fields changed again in the last two years? :stuck_out_tongue:

Any help is welcome.

PD: Also, if I try to change the e-mail to something else or to the old one, now I (admin) get the message “You did this action too many times. Please try again later”. How much time is later and why is the Admin rate limited on changing e-mails if I only did it once? I probably did something wrong and didn’t realized it :facepalm:

1 Like

So email delivery is working, maybe server time is off / incorrect? If your server time is off, this can happen.

It worked for me! If you’re still facing this problem (or for anyone else who finds this topic :sweat_smile:), I think you’d get that error if UserEmail.find_by(email: "") didn’t return anything. Might be worth double-checking if the email address matches exactly.

1 Like