# Adding post count to user card

**URL:** https://meta.discourse.org/t/adding-post-count-to-user-card/254128
**Category:** Feature
**Created:** [February 5, 2023, 6:56pm UTC](https://meta.discourse.org/t/adding-post-count-to-user-card/254128 "2023-02-05T18:56:16Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![rahim123](https://avatars.discourse-cdn.com/v4/letter/r/df705f/32.png) [@rahim123](https://meta.discourse.org/u/rahim123)
#### Post date: [February 5, 2023, 6:56pm UTC](https://meta.discourse.org/t/adding-post-count-to-user-card/254128/1 "2023-02-05T18:56:17Z")

</div>

Hi there, I know that Discourse doesn’t emphasize a user’s post count and instead focuses on reading time. But for my large migrated traditional forum userbase, post count is an important metric. It would be good to have the total post count (topics + replies) displayed in the popup user card instead of needing to go into the user’s summary page.

I’m trying to use this as a model, which does work to show the user’s “last seen” time:  
[https://github.com/tshenry/discourse-last-seen-user-card-theme-component/blob/main/common/head\_tag.html](https://github.com/tshenry/discourse-last-seen-user-card-theme-component/blob/main/common/head_tag.html)

But my version doesn’t work (I’m initially attempting to just show the the replies count):

#### Attempt 1:

```plaintext
<script type="text/x-handlebars" data-template-name="/connectors/user-card-metadata/post-count-metadata">
    {{#if user.summary.post_count}}
        <h3><span class='desc'>Count:</span> {{user.summary.post_count}}</h3>
    {{/if}}
</script>

```

#### Attempt 2:

```plaintext
<script type="text/x-handlebars" data-template-name="/connectors/user-card-metadata/post-count-metadata">
    {{#if user.post_count}}
        <h3><span class='desc'>Count:</span> {{user.post_count}}</h3>
    {{/if}}
</script>

```

#### Attempt 3:

```plaintext
<script type="text/x-handlebars" data-template-name="/connectors/user-card-metadata/post-count-metadata">
    {{#if user.stats.post_count}}
        <h3><span class='desc'>Count:</span> {{user.stats.post_count}}</h3>
    {{/if}}
</script>

```

It appears that the user stats model isn’t loaded for for that handlebar location and I don’t know how to access it. I found this:

> [@Show a user's reputation/user level next to their name](https://meta.discourse.org/t/show-a-users-reputation-user-level-next-to-their-name/29459/17):
>
> Hello, I just wanted to share my findings. Its not plugin ready, just quick hack to core files (sorry). But as inspiration for someone it may be handy… Add User Post Count in post template and user-card Use as example. It can be adjusted to display various user stats (post count, user\_last\_seen\_at, etc.) in user-card and in post stream. app/assets/javascripts/discourse/templates/user-card.hbs {{user-reputation post\_count=user.post\_count}} /assets/javascripts/discourse/components/user-reputat…

And this:

> [@api.decorateWidget - how can I find the template's names?](https://meta.discourse.org/t/api-decoratewidget-how-can-i-find-the-templates-names/172907/4):
>
> You aren’t going to be able to use decorateWidget() on a plugin outlet. Try something like this: \<script type="text/discourse-plugin" version="0.8.42"\> const h = require("virtual-dom").h; api.createWidget("user-card-custom-field", { html(attrs) { const userCustomFields = attrs.user.custom\_fields; if (userCustomFields.user\_field\_4) { return h('span.poster-user-field', userCustomFields.user\_field\_4); } } }); \</script\> \<script type="text…

Would I have to create a `discourse-plugin` script to access it and then create an HTML widget with `api.createWidget` ? Or is there an easier method to just use handlebars?
