Skip to:
Content
Pages
Categories
Search
Top
Bottom

Get total replies to a topic by the author of that topic

  • @thinlizzie

    Participant

    Hi Robin,

    I’m writing some code to pay a little “reward points” bonus to the author of a forum topic, when that topic receives X number of replies.
    All works fine, hooking to bbp_new_reply.
    But I would like to exclude any replies by the author themself from the total replies count.
    Total replies count is currently bbp_get_topic_reply_count( $topic_id )
    So I need to subtract author_own_replies from that total.

    I have $topic_id, $author_id, $reply_id, $forum_id

    Any easy way to achieve this?

    I’m trying to avoid SQL queries.

Viewing 1 replies (of 1 total)
  • @robin-w

    Moderator

    Very briefly tested as I am on holiday tomorrow, but try this

    $r = array(
    		'post_type'              =>bbp_get_reply_post_type(),   
    		'post_parent'            => $topic_id,  
    		'author__not_in' => array( $author_id)
    		);
    	$reply_posts = new WP_Query($r); 
    	$count = $reply_posts->post_count;
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.
Skip to toolbar