The discussion revolves around retrieving a user’s email address via the Discourse API. paully21 asks how to get a user’s email, noting that the previously available users/{username}/emails endpoint no longer works. j.jaffeux clarifies that GET /users/:username.json can return the email if the API key holder is the user themselves or a staff member with the appropriate permissions. j.jaffeux confirms this works for their own user, and j.jaffeux adds that staff can view emails if moderators_view_emails is enabled, though it logs a staff action. paully21 confirms the solution works after adjusting the request to a GET with .json in the URL, resolving the issue.
Is there a way to get a current e-mail address of a user via the API?
Our use case is this:
We allow users to manage their Discourse information via our website. In general, Discourse is only used as a mailing list and nearly all users never visit the actual Discourse site. I want to be able to show the user the current e-mail address that Discourse is using so they can see if it needs to be changed.
I am able to do this with all other fields except email.
There used to be an API endpoint users/{username}/emails but that doesn’t seem to be available anymore.
That worked…I had some old code that used to work (version 1.4 ish) that had the request as a PUT and without the .json at the end. I modified it to a GET and changed the URL and now it works.