bbp_update_topic_last_reply_id( int $topic_id, int $reply_id )

Update the topic with the most recent reply ID


Description Description


Parameters Parameters

$topic_id

(Optional) Topic id to update

$reply_id

(Optional) Reply id


Top ↑

Return Return

(int) Reply id


Top ↑

Source Source

File: includes/topics/functions.php

function bbp_update_topic_last_reply_id( $topic_id = 0, $reply_id = 0 ) {

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

	if ( empty( $reply_id ) ) {
		$reply_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( $reply_id ) || ! bbp_is_reply( $reply_id ) ) {
		$reply_id = 0;
	}

	$reply_id = (int) $reply_id;

	// Update if reply is published
	update_post_meta( $topic_id, '_bbp_last_reply_id', $reply_id );

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