# Can an admin change a user's email address?

**URL:** https://meta.discourse.org/t/can-an-admin-change-a-users-email-address/24525
**Category:** Support
**Tags:** email
**Created:** [January 28, 2015, 1:37pm UTC](https://meta.discourse.org/t/can-an-admin-change-a-users-email-address/24525 "2015-01-28T13:37:53Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![joshfrank](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/joshfrank/32/114706_2.png) [@joshfrank](https://meta.discourse.org/u/joshfrank)
#### Post date: [January 28, 2015, 1:37pm UTC](https://meta.discourse.org/t/can-an-admin-change-a-users-email-address/24525/1 "2015-01-28T13:37:53Z")

</div>

I’m getting situations where people need to change their email address but can’t get into Discourse to do it themselves, and are asking me, the admin, to do it for them. But I can’t see any way to do that, and so now I’ve got people who can’t get into the site. Is there a way for me to change a user’s email address?

---

<div class="post-metadata">

### Author: ![joshfrank](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/joshfrank/32/114706_2.png) [@joshfrank](https://meta.discourse.org/u/joshfrank)
#### Post date: [January 28, 2015, 1:52pm UTC](https://meta.discourse.org/t/can-an-admin-change-a-users-email-address/24525/2 "2015-01-28T13:52:32Z")

</div>

I figured it out, enough to solve my immediate problem anyway.

I’m not sure it’s the **best** way to solve it, but if I impersonate the user, I can then change the address. I think an admin should probably have this ability, but it doesn’t come up that much, so I can live with this for now.

---

<div class="post-metadata">

### Author: ![DeanMarkTaylor](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/deanmarktaylor/32/102462_2.png) [@DeanMarkTaylor](https://meta.discourse.org/u/DeanMarkTaylor)
#### Post date: [January 28, 2015, 11:01pm UTC](https://meta.discourse.org/t/can-an-admin-change-a-users-email-address/24525/3 "2015-01-28T23:01:44Z")

</div>

FYI:This was also recently discussed in a similar topic here although not 100% specific to your question:

> [@How can I manually change a User password?](https://meta.discourse.org/t/how-can-i-manually-change-a-user-password/24058):
>
> A user put a wrong email and forgot his password. How can I manually change his password? Thanks!

---

<div class="post-metadata">

### Author: ![joshfrank](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/joshfrank/32/114706_2.png) [@joshfrank](https://meta.discourse.org/u/joshfrank)
#### Post date: [January 28, 2015, 11:31pm UTC](https://meta.discourse.org/t/can-an-admin-change-a-users-email-address/24525/4 "2015-01-28T23:31:57Z")

</div>

Hmm, that thread does show a better way to do it. But why would it make sense to allow an admin to edit the user’s email address from the user’s preferences page (`/users/{user}/preferences`), but not the admin page for the same user (`/admin/users/{user}`). Surely the permissions should be the same on both?

However, this is still very helpful, thanks.

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [January 28, 2015, 11:32pm UTC](https://meta.discourse.org/t/can-an-admin-change-a-users-email-address/24525/5 "2015-01-28T23:32:13Z")

</div>

Slightly off-topic, But I’m curious.

As email address is _the_ primary way of establishing a member’s identity, how is one able to know that “member A” is not trying to get at “member B’s” account?

---

<div class="post-metadata">

### Author: ![joshfrank](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/joshfrank/32/114706_2.png) [@joshfrank](https://meta.discourse.org/u/joshfrank)
#### Post date: [January 28, 2015, 11:50pm UTC](https://meta.discourse.org/t/can-an-admin-change-a-users-email-address/24525/6 "2015-01-28T23:50:18Z")

</div>

I guess the admin would have to use his/her discretion. In this case, the user was `abc@domain.com`, and the entry in the db was `{SPACE}abc@domain.com`, and that leading space apparently matters. So it was pretty clear that I just needed to delete the space and fix an obvious typo.

Also, Discourse should probably trim leading and trailing whitespace, to prevent this obvious mistake.

---

<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: [January 29, 2015, 12:18am UTC](https://meta.discourse.org/t/can-an-admin-change-a-users-email-address/24525/7 "2015-01-29T00:18:35Z")

</div>

How did that leading space get in there? Did the user enter it?

---

<div class="post-metadata">

### Author: ![joshfrank](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/joshfrank/32/114706_2.png) [@joshfrank](https://meta.discourse.org/u/joshfrank)
#### Post date: [January 29, 2015, 11:50am UTC](https://meta.discourse.org/t/can-an-admin-change-a-users-email-address/24525/8 "2015-01-29T11:50:05Z")

</div>

Actually the user was created via a script calling the `/users` endpoint in the API, with data entered by the user, so really it’s a validation bug in my script, but probably the API should protect against this as well.

---

<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: [January 29, 2015, 11:52am UTC](https://meta.discourse.org/t/can-an-admin-change-a-users-email-address/24525/9 "2015-01-29T11:52:34Z")

</div>

You are probably right given the importance of email. @techAPJ can you make sure the API guards against (strips) extra leading or trailing spaces when entering emails? Perhaps it could be part of the validation steps somehow.

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [January 29, 2015, 7:57pm UTC](https://meta.discourse.org/t/can-an-admin-change-a-users-email-address/24525/10 "2015-01-29T19:57:26Z")

</div>

Just pushed a fix:

[https://github.com/discourse/discourse/pull/3150](https://github.com/discourse/discourse/pull/3150)

---

<div class="post-metadata">

### Author: ![SylvainKalache](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sylvainkalache/32/116954_2.png) [@SylvainKalache](https://meta.discourse.org/u/SylvainKalache)
#### Post date: [December 16, 2015, 8:14pm UTC](https://meta.discourse.org/t/can-an-admin-change-a-users-email-address/24525/11 "2015-12-16T20:14:26Z")

</div>

To come back to the original question, I am trying to achieve the same thing: change a user email. However I am trying to do this via the API.

Looking at the [documentation](https://meta.discourse.org/t/discourse-api-documentation/22706) it seems possible via: users/:username/preferences/email

However looking at [Discourse code](https://github.com/discourse/discourse/blob/master/app/controllers/users_controller.rb#L468) it seems that this will trigger a job to send a confirmation email to the user. Is there a way to change a user email without the user confirmation?

Even if it’s a hacky way, I REALLY need to do it and I would like to avoid changing the value directly in the DB…

---

<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: [December 16, 2015, 8:57pm UTC](https://meta.discourse.org/t/can-an-admin-change-a-users-email-address/24525/12 "2015-12-16T20:57:45Z")

</div>

That is very risky unless you know with 100% certainty that the email is valid, which implies SSO.

---

<div class="post-metadata">

### Author: ![joshfrank](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/joshfrank/32/114706_2.png) [@joshfrank](https://meta.discourse.org/u/joshfrank)
#### Post date: [December 16, 2015, 9:46pm UTC](https://meta.discourse.org/t/can-an-admin-change-a-users-email-address/24525/13 "2015-12-16T21:46:01Z")

</div>

Sometimes I know the email is valid because the user emailed **from that address** to ask me to change it for them in the system.

---

<div class="post-metadata">

### Author: ![SylvainKalache](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sylvainkalache/32/116954_2.png) [@SylvainKalache](https://meta.discourse.org/u/SylvainKalache)
#### Post date: [December 16, 2015, 10:33pm UTC](https://meta.discourse.org/t/can-an-admin-change-a-users-email-address/24525/14 "2015-12-16T22:33:57Z")

</div>

What I am trying to do is disabling a user and then give the opportunity for this same user to create another account with the same email address. That’s why I need to change/invalidate a user email address.

I know it does not sound like a regular usage of Discourse, just sharing it so that you guys have more context and you might have a different idea on how to achieve this.

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [December 16, 2015, 10:38pm UTC](https://meta.discourse.org/t/can-an-admin-change-a-users-email-address/24525/15 "2015-12-16T22:38:02Z")

</div>

I assume they are going to use a different username too? Why not just anonymize the account?

---

<div class="post-metadata">

### Author: ![SylvainKalache](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sylvainkalache/32/116954_2.png) [@SylvainKalache](https://meta.discourse.org/u/SylvainKalache)
#### Post date: [December 17, 2015, 12:01am UTC](https://meta.discourse.org/t/can-an-admin-change-a-users-email-address/24525/16 "2015-12-17T00:01:30Z")

</div>

That indeed works! Thank you @cpradio 🙂

---

<div class="post-metadata">

### Author: ![shahidmir](https://avatars.discourse-cdn.com/v4/letter/s/9dc877/32.png) [@shahidmir](https://meta.discourse.org/u/shahidmir)
#### Post date: [May 24, 2018, 9:25am UTC](https://meta.discourse.org/t/can-an-admin-change-a-users-email-address/24525/18 "2018-05-24T09:25:35Z")

</div>

Hi,  
Im trying all of the above but im simply not getting the edit pencil come up for changing the email address.  
Im using SSO to sign users into discourse and have set email to be editable. Any other config that i maybe missing?

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [May 25, 2018, 1:41am UTC](https://meta.discourse.org/t/can-an-admin-change-a-users-email-address/24525/19 "2018-05-25T01:41:19Z")

</div>

You need to edit the email at the SSO provider, or disable “sso overrides email” to let everyone change their own.

---

<div class="post-metadata">

### Author: ![shahidmir](https://avatars.discourse-cdn.com/v4/letter/s/9dc877/32.png) [@shahidmir](https://meta.discourse.org/u/shahidmir)
#### Post date: [May 25, 2018, 7:11am UTC](https://meta.discourse.org/t/can-an-admin-change-a-users-email-address/24525/20 "2018-05-25T07:11:44Z")

</div>

hmm, right, so i cant have SSO and edit ability together at the same time.

I do not want to disable SSO, but want to facilitate for the scenario when admin may have to manually change a users email address via the dashboard.

So my option is to temporarily switch off SSO, make the change and then switch it back on?  
I guess the impersonate option being spoken of above will also only work with SSO off?

Or i would have to make the change in the database directly.

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [May 25, 2018, 7:52am UTC](https://meta.discourse.org/t/can-an-admin-change-a-users-email-address/24525/21 "2018-05-25T07:52:02Z")

</div>

No, don’t disable SSO entirely - disable the `sso overrides email` setting.

[Next page](https://meta.discourse.org/t/can-an-admin-change-a-users-email-address/24525.md?page=2)
