Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to display the User Post Count in Topic.php

  • @vegasparty607

    Participant

    Hello, I want to display the user forum post count in the topic.php.

    I know where I must put it, under the `

    `, but I don’t know the code or function to put.

    Anybody have a solution? Thanks!

Viewing 8 replies - 1 through 8 (of 8 total)
  • @vegasparty607

    Participant

    bump

    @r-a-y

    Keymaster

    Use the Member Profile Stats plugin:
    https://wordpress.org/extend/plugins/buddypress-member-profile-stats/

    It comes with a set of handy template tags you can use like post count.

    @vegasparty607

    Participant

    Thanks for the reply.

    I tried putting in: “

    the topic.php by the poster avatar but I keep getting: “No Forum Posts yet” even though on their profile it says otherwise

    can u help me @r-a-y?

    @vegasparty607

    Participant

    and the:

    `function bp_member_profile_stats_member_posts_daysince() {
    echo bp_member_profile_stats_get_member_posts_daysince();`

    but i get unexpected errors mmmhm…

    should i be putting the function in bp-custom?

    @r-a-y

    Keymaster

    You’re using the plugin wrong.

    Member Profile Stats, by default, passes the displayed user ID for many of the template tags; you’ll need to pass the topic poster’s ID.

    eg. `bp_member_profile_stats_get_member_post_count( $user_id = false )`

    Unfortunately, there is no native function to pass the topic poster ID. However one can easily be created:

    `function my_topic_poster_id() {
    global $topic_template;
    return $topic_template->post->poster_id;
    }
    `

    Then you can pass it in the function:
    `echo bp_member_profile_stats_get_member_post_count( my_topic_poster_id() )`

    @vegasparty607

    Participant

    Thanks Man! that did it!

    @vegasparty607

    Participant

    Hey ray, i have a quick question.

    I have wp-ban installed, and it adds a function that fetch’s the IP address of the user logged in i think, it’s the standard function for calling it.

    the full code is here: https://buddypress.org/community/groups/how-to-and-troubleshooting/forum/topic/having-trouble-with-ip/#post-96715

    What i did is I put the function in the topic.php so it would show the poster’s IP address. Now knowing that that function only retrieves the current logged in user IP, I thought I could override this with your function above, (my_topic_poster_id) so it would display the IP address of the forum poster. (like the member stats), so put in topic.php

    `. `

    Will it pass the topic poster ID so it shows the forum poster’s IP and not mine?

    @r-a-y

    Keymaster

    If get_IP() can handle passing a $user_id, then yes it would work when you use that code snippet on a forum topic page.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘How to display the User Post Count in Topic.php’ is closed to new replies.
Skip to toolbar