Skip to:

Could anyone fix this code to count user posts?

  • davidwood9999


    Hey guys – props to @3sixty for posting the below code.

    I wonder – could anyone possibly show me (a php noob I’m afraid) how to tweak this to show the user’s new forum topics:

    1) For a specific forum (e.g. forum_name=”Impact”), and

    2) Between STARTDATE and ENDDATE?

    3) How to show total for ALL users, for forum_name=”Impact” between STARTDATE and ENDDATE?

    Any help MUCH appreciated.


    function get_new_forum_topic_count_by_user( $user_id ) {

    $args = array(

    ‘per_page’ => 10000,

    ‘show_hidden’ => true,

    ‘user_id’ => $user_id,

    ‘action’ => ‘new_forum_topic’


    if ( bp_has_activities( $args ) ) {

    global $activities_template;

    $count = $activities_template->total_activity_count;

    } else {

    $count = 0;


    return $count;


Viewing 2 replies - 1 through 2 (of 2 total)

  • davidwood9999


    Curious if I’m phrasing my questions wrong? I’m new to this forum and I notice my first three posts have received zero replies.

    Is it because I”m Australian? 🙂



    These types of posts get replies if someone feels they want to help. They are not problems with BuddyPress core but customizations.

    Your code example uses the activities loop which is not best way to find forum topic counts. Because you want to specify a date range you might have to query the db directly. Look at this function that returns total topic count for a user

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Could anyone fix this code to count user posts?’ is closed to new replies.
Skip to toolbar