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

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


Description Description


Parameters Parameters

$topic_id

(Optional) Topic id.

$new_time

(Optional) New time in mysql format.

Default value: ''


Top ↑

Return Return

(string) MySQL timestamp of last active reply


Top ↑

Source Source

File: includes/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)
	$topic_id = bbp_is_reply( $topic_id )
		? bbp_get_reply_topic_id( $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 );
	}

	// Filter & return
	return apply_filters( 'bbp_update_topic_last_active_time', $new_time, $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.