bbp_update_forum_reply_count_hidden( int $forum_id )

Adjust the total hidden reply count of a forum


Description Description


Parameters Parameters

$forum_id

(Optional) Forum id or topic id. It is checked whether it is a topic or a forum. If it's a topic, its parent, i.e. the forum is automatically retrieved.


Top ↑

Return Return

(int) Forum reply count


Top ↑

Source Source

File: includes/forums/functions.php

function bbp_update_forum_reply_count_hidden( $forum_id = 0 ) {

	$forum_id = bbp_get_forum_id( $forum_id );
	$children_reply_count = 0;

	// Loop through children and add together forum reply counts
	$children = bbp_forum_query_subforum_ids( $forum_id );
	if ( ! empty( $children ) ) {
		foreach ( (array) $children as $child ) {
			$children_reply_count += bbp_update_forum_reply_count_hidden( $child );
		}
	}

	// Don't count replies if the forum is a category
	$reply_count = ! bbp_is_forum_category( $forum_id )
		? bbp_get_non_public_child_count( $forum_id, bbp_get_reply_post_type() )
		: 0;

	// Calculate total replies in this forum
	$total_replies = (int) ( $reply_count + $children_reply_count );

	// Update the counts
	update_post_meta( $forum_id, '_bbp_reply_count_hidden',       $reply_count   );
	update_post_meta( $forum_id, '_bbp_total_reply_count_hidden', $total_replies );

	// Filter & return
	return (int) apply_filters( 'bbp_update_forum_reply_count_hidden', $total_replies, $forum_id );
}

Top ↑

Changelog Changelog

Changelog
Version Description
2.6.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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