Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: How do you show a member's total post count?


snark
Participant

@snark

Thanks @boonebgorges — I got it partially working, but then got stuck. I put the function as is above in my functions.php file, and added this to member-header.php:

<p><?php echo get_activity_count_by_user( bp_current_user_id() ) ?> Forum posts</p>

This returned ALL posts for a user, including blog posts. Obviously, based on the text I added above, I only want to include Forum posts (should include both Topics and Replies). I looked at the page you suggested — https://codex.buddypress.org/developer-docs/custom-buddypress-loops/the-activity-stream-loop/ — but I couldn’t figure out how or where to implement the filter: what syntax, and where does it go, in the function or in the call-out?

Also: Using “bp_current_user_id() ” allows the post count to display on the user’s profile page, but how do I display the post count on a different page, such as /single/forum/topic.php, the Forum topics display page, where “bp_current_user_id()” is no longer applicable? On that page I’d like to put a user’s post count in parenthesis next to the user, like this: “John Doe (54 posts)”. That way when you scanned the list of Replies to a Topic, you would quickly see if a user was a long-term and/or hardcore user or a noob based on the number of posts they have contributed to the site, and I’m hoping that little ego boost will help nudge people into posting more frequently. Does that make sense?

Thanks again for all your help.

Skip to toolbar