bbp_update_topic_anonymous_reply_count( int $topic_id )

Adjust the total anonymous reply count of a topic


Description Description


Parameters Parameters

$topic_id

(Optional) Topic id to update


Top ↑

Return Return

(int) Anonymous reply count


Top ↑

Source Source

File: includes/topics/functions.php

function bbp_update_topic_anonymous_reply_count( $topic_id = 0 ) {

	// If it's a reply, then get the parent (topic id)
	$topic_id = bbp_is_reply( $topic_id )
		? bbp_get_reply_topic_id( $topic_id )
		: bbp_get_topic_id( $topic_id );

	// Query the DB to get anonymous replies in this topic
	$bbp_db  = bbp_db();
	$query   = $bbp_db->prepare( "SELECT COUNT( ID ) FROM {$bbp_db->posts} WHERE ( post_parent = %d AND post_status = %s AND post_type = %s AND post_author = 0 ) OR ( ID = %d AND post_type = %s AND post_author = 0 )", $topic_id, bbp_get_public_status_id(), bbp_get_reply_post_type(), $topic_id, bbp_get_topic_post_type() );
	$replies = (int) $bbp_db->get_var( $query );

	update_post_meta( $topic_id, '_bbp_anonymous_reply_count', $replies );

	// Filter & return
	return (int) apply_filters( 'bbp_update_topic_anonymous_reply_count', $replies, $topic_id );
}

Top ↑

Changelog Changelog

Changelog
Version Description
2.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.