# How to know if user is using a default avatar

**URL:** <https://meta.discourse.org/t/how-to-know-if-user-is-using-a-default-avatar/58915>\
**Category:** Support\
**Created:** [2017年三月12日 08:08 UTC](https://meta.discourse.org/t/how-to-know-if-user-is-using-a-default-avatar/58915 "2017-03-12T08:08:53Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![hnaseri](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hnaseri/32/120660_2.png) [@hnaseri](https://meta.discourse.org/u/hnaseri)\
**Post date:** [2017年三月12日 08:08 UTC](https://meta.discourse.org/t/how-to-know-if-user-is-using-a-default-avatar/58915/1 "2017-03-12T08:08:53Z")

</div>

I want to encourage my users to upload an avatar via api.  
How can I know a user is using default avatar in discourse? because I don’t want to warn users that already have gravatars or their custom avatars set.

---

<div class="post-metadata">

**Author:** ![hnaseri](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hnaseri/32/120660_2.png) [@hnaseri](https://meta.discourse.org/u/hnaseri)\
**Post date:** [2017年三月12日 11:15 UTC](https://meta.discourse.org/t/how-to-know-if-user-is-using-a-default-avatar/58915/2 "2017-03-12T11:15:10Z")

</div>

I don’t know if its a good solution, but my solution for now is to look for `gravatar_avatar_upload_id` and `custom_avatar_upload_id` in `/users/{username}.json` and to see if they are both set to `null`.

Any idea?

---

<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:** [2017年三月12日 11:39 UTC](https://meta.discourse.org/t/how-to-know-if-user-is-using-a-default-avatar/58915/3 "2017-03-12T11:39:58Z")

</div>

I think it is the correct solution for you. For my knowledge only three types of avatars are there in Discourse (letter, gravatar and custom avatars). So it must work.

---

<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:** [2017年三月12日 11:42 UTC](https://meta.discourse.org/t/how-to-know-if-user-is-using-a-default-avatar/58915/4 "2017-03-12T11:42:07Z")

</div>

Out of curiosity: do you know we already show a JIT message to users with default avatar?

> <https://github.com/discourse/discourse/blob/d27575176a274ddee7513fb2d43aa9e453f9a68b/lib/composer_messages_finder.rb#L58-L81>

---

<div class="post-metadata">

**Author:** ![hnaseri](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hnaseri/32/120660_2.png) [@hnaseri](https://meta.discourse.org/u/hnaseri)\
**Post date:** [2017年三月12日 12:03 UTC](https://meta.discourse.org/t/how-to-know-if-user-is-using-a-default-avatar/58915/5 "2017-03-12T12:03:06Z")

</div>

Yes I know. But I have implemented discourse in my application and users mostly post there. So i don’t know If this JIT message could be get with an api call. If it could be, I can call it when users perform some actions inside the application. But if it couldn’t be called with api call, I need to write a custom code for it.

---

<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:** [2017年三月12日 12:04 UTC](https://meta.discourse.org/t/how-to-know-if-user-is-using-a-default-avatar/58915/6 "2017-03-12T12:04:53Z")

</div>

> [@hnaseri](#):
>
> So i don’t know If this JIT message could be get with an api call.

These education messages are associated with the composer. I don’t know the exact endpoint, but I’m pretty sure you can get them via the API since it’s working in Discourse 😉

---

<div class="post-metadata">

**Author:** ![hnaseri](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hnaseri/32/120660_2.png) [@hnaseri](https://meta.discourse.org/u/hnaseri)\
**Post date:** [2017年三月12日 12:08 UTC](https://meta.discourse.org/t/how-to-know-if-user-is-using-a-default-avatar/58915/7 "2017-03-12T12:08:11Z")

</div>

So how should I reverse engineer it? Any idea? I need to make an account without avatar and wait for this message to appear? This is somehow awkward.

---

<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:** [2017年三月12日 12:12 UTC](https://meta.discourse.org/t/how-to-know-if-user-is-using-a-default-avatar/58915/8 "2017-03-12T12:12:00Z")

</div>

> [@hnaseri](#):
>
> So how should I reverse engineer it? Any idea?

The endpoint is `/composer_messages.json` 😉

---

<div class="post-metadata">

**Author:** ![hnaseri](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hnaseri/32/120660_2.png) [@hnaseri](https://meta.discourse.org/u/hnaseri)\
**Post date:** [2017年三月12日 12:19 UTC](https://meta.discourse.org/t/how-to-know-if-user-is-using-a-default-avatar/58915/9 "2017-03-12T12:19:38Z")

</div>

> [@zogstrip](#):
>
> The endpoint is /composer\_messages.json 😉

Thank you very much. But how I can actually use it? 🤔  
For example when user write their first topic in my app, I want to call this JIT and show the message.

---

<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:** [2017年三月12日 12:21 UTC](https://meta.discourse.org/t/how-to-know-if-user-is-using-a-default-avatar/58915/10 "2017-03-12T12:21:51Z")

</div>

> [@hnaseri](#):
>
> But how I can actually use it? 🤔

You might want to look at the `ComposerMessagesControllers`’ source code 😉

> <https://github.com/discourse/discourse/blob/main/app/controllers/composer_messages_controller.rb>

---

<div class="post-metadata">

**Author:** ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)\
**Post date:** [2019年五月12日 21:51 UTC](https://meta.discourse.org/t/how-to-know-if-user-is-using-a-default-avatar/58915/11 "2019-05-12T21:51:10Z")

</div>



---

<div class="post-metadata">

**Author:** ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)\
**Post date:** [2019年五月12日 22:58 UTC](https://meta.discourse.org/t/how-to-know-if-user-is-using-a-default-avatar/58915/12 "2019-05-12T22:58:56Z")

</div>

To figure out the list you can use [data explorer](https://meta.discourse.org/t/32566?silent=true):

```plaintext
SELECT id user_id from users
WHERE uploaded_avatar_id IS NULL 

```

---

<div class="post-metadata">

**Author:** ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)\
**Post date:** [2019年六月11日 22:58 UTC](https://meta.discourse.org/t/how-to-know-if-user-is-using-a-default-avatar/58915/13 "2019-06-11T22:58:57Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
