Hi,
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.
Users are discussing how to change a user’s email address in Discourse, especially when users can’t do it themselves and verification steps are unwanted. testingsoftware initially asks how to change an email, noting no option exists in the profile. HAWK asks if SSO is in use, which testingsoftware confirms is not. schungx suggests deactivating, changing, and reactivating the account, but notes this no longer works without verification. codinghorror clarifies that only staff face dual-email verification. bekircem reports the method no longer works, prompting jomaxro to ask for specifics. testingsoftware notes email change is possible via Preferences, but schungx confirms verification is still required. schungx then links to a workaround using Rails console commands. gigperformer struggles with syntax, later realizing commands must be entered line-by-line after waiting for Rails to load. schleifer and schungx clarify the multi-line format. gigperformer suggests preserving line breaks in excerpts for clarity. fidelio reports an error (NoMethodError: undefined method 'update' for nil:NilClass), and zogstrip explains this means no matching UserEmail record exists — likely due to a typo or deleted record. The thread concludes that manual email changes require Rails console access and careful syntax, with verification bypass possible only via direct database manipulation.
Hi,
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.
There is a topic on this. Pls search.
Short answer: Deactivate the account, change email, reactivate.
Are you referring to staff? Only staff have the restriction that both emails must be confirmed for security reasons.
It does not work anymore. ![]()
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
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.
The way to do this now is:
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: "oid@example.com").update(email: "new@example.com")
which didn’t work and then I tried
cd /var/discourse
sudo ./launcher enter app rails c
UserEmail.find_by(email: "oid@example.com").update(email: "new@example.com")
(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?
Four lines, just as shown in the linked topic:
cd /var/discoursesudo ./launcher enter apprails cUserEmail.find_by(email: "oid@example.com").update(email: "new@example.com")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.
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.
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.
For some reason this seems to have stopped working for me. I did an edit on a users email but made a mistake with the name. Now every time I run :UserEmail.find_by(email: “oid@example.com”).update(email: “new@example.com”)
I get: NoMethodError: undefined method `update’ for nil:NilClass
Has something changed?
Try UserEmail.find_by(email: "oid@example.com") alone, if it returns nil, then it means there are no UserEmail records with that email address ![]()