bbp_update_topic_last_active_time( int $topic_id, string $new_time = '' )

Update the topics last active date/time (aka freshness)

Description

Parameters

$topic_id

(Optional) Topic id

$new_time

(Optional) New time in mysql format

Default value: ''

Return

(bool) True on success, false on failure

Source

File: bp-forums/topics/functions.php

function bbp_update_topic_last_active_time( $topic_id = 0, $new_time = '' ) {

	// If it's a reply, then get the parent (topic id)
	if ( bbp_is_reply( $topic_id ) ) {
		$topic_id = bbp_get_reply_topic_id( $topic_id );
	} else {
		$topic_id = bbp_get_topic_id( $topic_id );
	}

	// Check time and use current if empty
	if ( empty( $new_time ) ) {
		$new_time = get_post_field( 'post_date', bbp_get_public_child_last_id( $topic_id, bbp_get_reply_post_type() ) );
	}

	// Update only if published
	if ( !empty( $new_time ) ) {
		update_post_meta( $topic_id, '_bbp_last_active_time', $new_time );
	}

	return apply_filters( 'bbp_update_topic_last_active_time', $new_time, $topic_id );
}

Changelog

Changelog
Version Description
bbPress (r2680) Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.