# Find a user by ID or username?

**URL:** https://meta.discourse.org/t/find-a-user-by-id-or-username/62582
**Category:** Development
**Created:** [May 12, 2017, 12:22pm UTC](https://meta.discourse.org/t/find-a-user-by-id-or-username/62582 "2017-05-12T12:22:21Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Radulf](https://avatars.discourse-cdn.com/v4/letter/r/5e9695/32.png) [@Radulf](https://meta.discourse.org/u/Radulf)
#### Post date: [May 12, 2017, 12:22pm UTC](https://meta.discourse.org/t/find-a-user-by-id-or-username/62582/1 "2017-05-12T12:22:21Z")

</div>

And another “simple” question from me and basically a follow up to [Showing simple text with decorateWidget - #5 by vinothkannans](https://meta.discourse.org/t/showing-simple-text-with-decoratewidget/62521/5)

I want to decorate the post with a custom field from the posting user. To do this, I want to get the user object. I already realized, that I can get the username or user\_id from the helper, i.e.,

```
var username = helper.attrs.username
var user_id = helper.attrs.user_id

```

How can I reach the user object from there? I found something about a User.find() method somewhere, but I’m not able to access it even though I import User from discourse/models/user. I also try to user Discourse.User.findByUsername(), but that returns a Promise and I have no idea how to handle that.

Do I need some additional imports or am I doing things wrong? Thanks a lot!

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [May 12, 2017, 12:35pm UTC](https://meta.discourse.org/t/find-a-user-by-id-or-username/62582/2 "2017-05-12T12:35:23Z")

</div>

Through plugin API you can do below

[https://github.com/discourse/discourse/blob/master/app/assets/javascripts/discourse/lib/plugin-api.js.es6#L178-L193](https://github.com/discourse/discourse/blob/master/app/assets/javascripts/discourse/lib/plugin-api.js.es6#L178-L193)

Then you can get that addition attributes like `helper.attrs.poster_age` and `helper.attrs.poster_height`. Also don’t forgot to add these attributes in post serializer.

---

<div class="post-metadata">

### Author: ![Radulf](https://avatars.discourse-cdn.com/v4/letter/r/5e9695/32.png) [@Radulf](https://meta.discourse.org/u/Radulf)
#### Post date: [May 12, 2017, 1:30pm UTC](https://meta.discourse.org/t/find-a-user-by-id-or-username/62582/3 "2017-05-12T13:30:02Z")

</div>

That’s a nice idea. However, I don’t think it will work in my specific case. I didn’t mention that the shown information should be restricted.

How I understand the serializer, the data would be sent to every user within the json file. Thus, the data would be accessible for everyone. Or is it possible to only add the data to the serializer for specific users?

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [May 12, 2017, 1:31pm UTC](https://meta.discourse.org/t/find-a-user-by-id-or-username/62582/4 "2017-05-12T13:31:56Z")

</div>

You can add any conditions on serializer. You may restrict guests, groups, non-staff users, etc.,
