Can an admin change a user's email address?

sorry, yes thats what i meant :slight_smile:
thanks

As forum admin, I like to change the e-mail of a user. The user’s e-mail provider went out of business.

I know the user and the user is authenticated to me by authenticated e-mail (gpg / OpenPGP) so I have no doubts about the legitimacy of the request.

Discourse sends a verification e-mail to the old e-mail address which will never arrive. Hence, e-mail cannot be updated.

Any advice?

If you have access to the site’s rails console, you can change email addresses without triggering a confirmation email.

Enter the docker container and then launch the rails console:

./launcher enter app 
rails c

Then find the user from their current email address:

u = User.find_by_email('oldemail@example.com')

Then update the email address:

u.update(email: 'newemail@example.com')

EDIT:
After updating the user’s email address though the command line, go to the Admin / Users page for the user. In the Permissions section of that page, click the ‘Deactivate Account’ button. You will then see two new buttons, ‘Send Activation Email’, and ‘Activate Account.’ Click the ‘Send Activation Email’ button. This will send the ‘Welcome to Discourse!’ email to the new email address. The user can click the link in that email to reaccess their account.

If the user is an Admin, you’ll have to Revoke Admin access first to be able to Deactivate Account.

12 Likes

This works initially but e-mail is subsequently automatically reset to old e-mail address.

User reported “This sends out new account creation confirmation.”

The old e-mail (provider no longer existing) is probably receiving a confirmation mail which the user cannot confirm. Hence, back to square one.

Are you using SSO to log users into Discourse?

3 Likes

Sorry, you are right. I have used this method for updating email addresses for sites that are using SAML login, and it works. For sites using password logins you need to do one more step.

After updating the user’s email address though the command line, go to the Admin / Users page for the user. In the Permissions section of that page, click the ‘Deactivate Account’ button. You will then see two new buttons, ‘Send Activation Email’, and ‘Activate Account.’ Click the ‘Send Activation Email’ button. This will send the ‘Welcome to Discourse!’ email to the new email address. The user can click the link in that email to reaccess their account.

If I find a more straightforward way of doing this, I’ll update my post.

4 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.