Adding post count to user card

AI-generated summary

The discussion revolves around adding a user’s post count to their user card in a Discourse forum. rahim123 wants to display the total post count (topics + replies) in the popup user card, rather than requiring users to visit the summary page. Despite referencing existing themes and scripts, their attempts to access the user stats model using handlebars have been unsuccessful. They are now considering creating a discourse-plugin script and HTML widget to achieve this, but are seeking easier alternatives.

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

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

Attempt 1:

<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:

<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:

<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:

And this:

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?