bbp_update_topic_voice_count( int $topic_id )

Adjust the total voice count of a topic


Description Description


Parameters Parameters

$topic_id

(Optional) Topic id to update


Top ↑

Return Return

(int) Voice count


Top ↑

Source Source

File: includes/topics/functions.php

function bbp_update_topic_voice_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 );

	// Bail if no topic ID
	if ( empty( $topic_id ) ) {
		return;
	}

	// Count the engagements
	$count = count( bbp_get_topic_engagements( $topic_id ) );

	// Update the voice count for this topic id
	update_post_meta( $topic_id, '_bbp_voice_count', $count );

	// Filter & return
	return (int) apply_filters( 'bbp_update_topic_voice_count', $count, $topic_id );
}

Top ↑

Changelog Changelog

Changelog
Version Description
2.6.0 bbPress (r6515) This must be called after any engagement changes
2.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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