Skip to:
Content
Pages
Categories
Search
Top
Bottom

Could anyone fix this code to count user posts?

  • Profile photo of davidwood9999
    davidwood9999
    Participant

    @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)
  • Profile photo of davidwood9999
    davidwood9999
    Participant

    @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? :-)

    Profile photo of @modemlooper
    @modemlooper
    Moderator

    @modemlooper

    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

    http://phpxref.ftwr.co.uk/buddypress/nav.html?bp-forums/bp-forums-functions.php.source.html#l367

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.