bbp_update_topic_last_active_id( int $topic_id, int $active_id )

Update the topic with the last active post ID


Description Description


Parameters Parameters

$topic_id

(Optional) Topic id to update

$active_id

(Optional) active id


Top ↑

Return Return

(int) Active id


Top ↑

Source Source

File: includes/topics/functions.php

function bbp_update_topic_last_active_id( $topic_id = 0, $active_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 );

	// Get last public active id if not passed
	if ( empty( $active_id ) ) {
		$active_id = bbp_get_public_child_last_id( $topic_id, bbp_get_reply_post_type() );
	}

	// Adjust last_id's based on last_reply post_type
	if ( empty( $active_id ) || ! bbp_is_reply( $active_id ) ) {
		$active_id = $topic_id;
	}

	$active_id = (int) $active_id;

	// Update only if published
	update_post_meta( $topic_id, '_bbp_last_active_id', $active_id );

	// Filter & return
	return (int) apply_filters( 'bbp_update_topic_last_active_id', $active_id, $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.