# Changing users email address

**URL:** https://meta.discourse.org/t/changing-users-email-address/72119
**Category:** Support
**Created:** [October 15, 2017, 10:58pm UTC](https://meta.discourse.org/t/changing-users-email-address/72119 "2017-10-15T22:58:21Z")
**Posts on this page:** 18
**Page:** 1

<div class="post-metadata">

### Author: ![testingsoftware](https://avatars.discourse-cdn.com/v4/letter/t/f1d935/32.png) [@testingsoftware](https://meta.discourse.org/u/testingsoftware)
#### Post date: [October 15, 2017, 10:58pm UTC](https://meta.discourse.org/t/changing-users-email-address/72119/1 "2017-10-15T22:58:21Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![HAWK](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hawk/32/86627_2.png) [@HAWK](https://meta.discourse.org/u/HAWK)
#### Post date: [October 15, 2017, 11:03pm UTC](https://meta.discourse.org/t/changing-users-email-address/72119/2 "2017-10-15T23:03:31Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![testingsoftware](https://avatars.discourse-cdn.com/v4/letter/t/f1d935/32.png) [@testingsoftware](https://meta.discourse.org/u/testingsoftware)
#### Post date: [October 15, 2017, 11:07pm UTC](https://meta.discourse.org/t/changing-users-email-address/72119/3 "2017-10-15T23:07:55Z")

</div>

no, SSO options are ticked off.

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

---

<div class="post-metadata">

### Author: ![schungx](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/schungx/32/70989_2.png) [@schungx](https://meta.discourse.org/u/schungx)
#### Post date: [October 15, 2017, 11:30pm UTC](https://meta.discourse.org/t/changing-users-email-address/72119/4 "2017-10-15T23:30:54Z")

</div>

There is a topic on this. Pls search.

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

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [October 16, 2017, 2:31am UTC](https://meta.discourse.org/t/changing-users-email-address/72119/5 "2017-10-16T02:31:55Z")

</div>

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

---

<div class="post-metadata">

### Author: ![bekircem](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bekircem/32/44582_2.png) [@bekircem](https://meta.discourse.org/u/bekircem)
#### Post date: [November 9, 2017, 10:19am UTC](https://meta.discourse.org/t/changing-users-email-address/72119/6 "2017-11-09T10:19:50Z")

</div>

It does not work anymore. ☹

---

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [November 9, 2017, 6:23pm UTC](https://meta.discourse.org/t/changing-users-email-address/72119/7 "2017-11-09T18:23:49Z")

</div>

> [@bekircem](#):
>
> It does not work anymore. ☹

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

---

<div class="post-metadata">

### Author: ![testingsoftware](https://avatars.discourse-cdn.com/v4/letter/t/f1d935/32.png) [@testingsoftware](https://meta.discourse.org/u/testingsoftware)
#### Post date: [November 9, 2017, 9:47pm UTC](https://meta.discourse.org/t/changing-users-email-address/72119/8 "2017-11-09T21:47:21Z")

</div>

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

---

<div class="post-metadata">

### Author: ![schungx](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/schungx/32/70989_2.png) [@schungx](https://meta.discourse.org/u/schungx)
#### Post date: [January 10, 2018, 3:01am UTC](https://meta.discourse.org/t/changing-users-email-address/72119/9 "2018-01-10T03:01:57Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![schungx](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/schungx/32/70989_2.png) [@schungx](https://meta.discourse.org/u/schungx)
#### Post date: [January 10, 2018, 3:15am UTC](https://meta.discourse.org/t/changing-users-email-address/72119/10 "2018-01-10T03:15:34Z")

</div>

The way to do this now is:

> [@Change user's email without verification](https://meta.discourse.org/t/change-users-email-without-verification/66602/7):
>
> 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: "oid@example.com").update(email: "new@example.com")

---

<div class="post-metadata">

### Author: ![gigperformer](https://avatars.discourse-cdn.com/v4/letter/g/94ad74/32.png) [@gigperformer](https://meta.discourse.org/u/gigperformer)
#### Post date: [November 16, 2018, 12:03am UTC](https://meta.discourse.org/t/changing-users-email-address/72119/11 "2018-11-16T00:03:57Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![schleifer](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/schleifer/32/86416_2.png) [@schleifer](https://meta.discourse.org/u/schleifer)
#### Post date: [November 16, 2018, 1:53am UTC](https://meta.discourse.org/t/changing-users-email-address/72119/12 "2018-11-16T01:53:01Z")

</div>

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: "oid@example.com").update(email: "new@example.com")`

---

<div class="post-metadata">

### Author: ![gigperformer](https://avatars.discourse-cdn.com/v4/letter/g/94ad74/32.png) [@gigperformer](https://meta.discourse.org/u/gigperformer)
#### Post date: [November 16, 2018, 3:44am UTC](https://meta.discourse.org/t/changing-users-email-address/72119/13 "2018-11-16T03:44:58Z")

</div>

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

 ![screenshot_3176](https://global.discourse-cdn.com/meta/original/3X/6/1/61103a470d5c77db95ac3348c33b142664aea304.png)

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.

---

<div class="post-metadata">

### Author: ![schungx](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/schungx/32/70989_2.png) [@schungx](https://meta.discourse.org/u/schungx)
#### Post date: [November 16, 2018, 5:18am UTC](https://meta.discourse.org/t/changing-users-email-address/72119/14 "2018-11-16T05:18:47Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![gigperformer](https://avatars.discourse-cdn.com/v4/letter/g/94ad74/32.png) [@gigperformer](https://meta.discourse.org/u/gigperformer)
#### Post date: [November 16, 2018, 1:52pm UTC](https://meta.discourse.org/t/changing-users-email-address/72119/15 "2018-11-16T13:52:25Z")

</div>

> [@schungx](#):
>
> 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.

---

<div class="post-metadata">

### Author: ![fidelio](https://avatars.discourse-cdn.com/v4/letter/f/f1d935/32.png) [@fidelio](https://meta.discourse.org/u/fidelio)
#### Post date: [March 15, 2019, 7:59am UTC](https://meta.discourse.org/t/changing-users-email-address/72119/16 "2019-03-15T07:59:23Z")

</div>

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](mailto:oid@example.com)”).update(email: “[new@example.com](mailto:new@example.com)”)  
I get: NoMethodError: undefined method `update’ for nil:NilClass  
Has something changed?

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [March 15, 2019, 11:15am UTC](https://meta.discourse.org/t/changing-users-email-address/72119/17 "2019-03-15T11:15:11Z")

</div>

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 😉

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [May 4, 2022, 7:55am UTC](https://meta.discourse.org/t/changing-users-email-address/72119/19 "2022-05-04T07:55:31Z")

</div>


