# Use the API to find a username based on an email?

**URL:** https://meta.discourse.org/t/use-the-api-to-find-a-username-based-on-an-email/45424
**Category:** Development
**Tags:** rest-api
**Created:** [8 ביוני,‏ 2016,‏ 9:50am UTC](https://meta.discourse.org/t/use-the-api-to-find-a-username-based-on-an-email/45424 "2016-06-08T09:50:22Z")
**Posts on this page:** 1
**Showing post:** 5

<div class="post-metadata">

### Author: ![alehandrof](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alehandrof/32/119526_2.png) [@alehandrof](https://meta.discourse.org/u/alehandrof)
#### Post date: [24 ביולי,‏ 2016,‏ 9:30am UTC](https://meta.discourse.org/t/use-the-api-to-find-a-username-based-on-an-email/45424/5 "2016-07-24T09:30:10Z")

</div>

I don’t follow ☹

The API I linked to works by filtering (which I didn’t know what possible) the list of active users by their email. Not sure how I’d trigger this in thew web UI.

```php
function getUsernameByEmail($email)
{
    $users = $this->_getRequest("/admin/users/list/active.json?filter=".urlencode($email));
    foreach($users->apiresult as $user) {
        if($user->email === $email) {
            return $user->username;
        }
    }
    return false;
}

```

BTW, let me clarify something in my previous response: I did get the API I linked to to work just fine. I just had trouble with other forks of it.

One thing I’d like to update during SSO is the user’s website field. I tried changing it in the admin to see what happens in the Network tab, but I don’t understand what I’m looking for. (AFAICT, I can’t add the website to the SSO payload, but I should be able to add another step that changes the website right before submitting the payload.)

---

_[View the full topic](https://meta.discourse.org/t/use-the-api-to-find-a-username-based-on-an-email/45424)._
