Changing users email address



I found the email template “confirm old email” which says that "Before we can change your email address, we need you to…"
How can I change any user email address? I cannot see any option in the profile, only the “show” option.


Are you using SSO? If so, it’s likely that your email addresses/usernames are being handled outside of native Discourse by the SSO authenticator.


no, SSO options are ticked off.

If users cannot change their email address themselves, I was wondering how can I change it for them.

(Stephen Chung) #4

There is a topic on this. Pls search.

Short answer: Deactivate the account, change email, reactivate.

(Jeff Atwood) #5

Are you referring to staff? Only staff have the restriction that both emails must be confirmed for security reasons.


It does not work anymore. :frowning:

(Joshua Rosenfeld) #7

Can you be more specific? What exactly doesn’t work anymore?


Also, selecting user, then Show Public Profile, Preferences. Here one can change the email

(Stephen Chung) #9

Nope. Not any more. It seems to send an email asking for verification.

This topic is asking how to change the email address without the verification step.

(Stephen Chung) #10

The way to do this now is:

(David Jameson) #11

I just tried this (assuming that the cd /var/discourse is a line by itself and that sudo … is a separate line) and I just got the error:

-bash: syntax error near unexpected token ‘(’

Then I tried

cd /var/discourse 
sudo ./launcher enter app rails c UserEmail.find_by(email: "").update(email: "")

which didn’t work and then I tried

cd /var/discourse 
sudo ./launcher enter app rails c 
UserEmail.find_by(email: "").update(email: "")

(using the appropriate email addresses of course) and got the error

bash: syntax error near unexpected token `email:'

So how exactly should this be entered?

(Andrew Schleifer) #12

Four lines, just as shown in the linked topic:

  1. cd /var/discourse
  2. sudo ./launcher enter app
  3. rails c
  4. UserEmail.find_by(email: "").update(email: "")

(David Jameson) #13

For the record, if you just read the text, you see everything merged into a single line

However, I had tried that and it didn’t seem to work either. Turns out one has to wait about 30 seconds and then I got a message “This monkey patch is no longer required”, then another 15 seconds delay and finally a prompt

 [1] pry(main)

and now it worked.

(I’m posting this in case anyone else runs into the same issue - quite likely if one is not experienced with ruby and rails, etc)

Thanks for the help.

(Stephen Chung) #14

Or you should click into the linked post and you’ll find that there are actually four commands in four separate lines.

What you see here is simply an excerpt of the post with all the line breaks removed and merged into one line in order to save space.

(David Jameson) #15

Sorry but it was not obvious to me at the time. Maybe excerpts of posts that have commands in them should not have their line endings removed.