bbp_untrash_topic_replies( int $topic_id )

Untrash replies to a topic previously trashed.


Description Description

Usually you’ll want to do this after the topic is unspammed.


Parameters Parameters

$topic_id

(Required)


Top ↑

Source Source

File: includes/topics/functions.php

function bbp_untrash_topic_replies( $topic_id = 0 ) {

	// Validation
	$topic_id = bbp_get_topic_id( $topic_id );

	// Get the replies that were not previously trashed
	$pre_trashed_replies = get_post_meta( $topic_id, '_bbp_pre_trashed_replies', true );

	// There are replies to untrash
	if ( ! empty( $pre_trashed_replies ) ) {

		// Maybe reverse the trashed replies array
		if ( is_array( $pre_trashed_replies ) ) {
			$pre_trashed_replies = array_reverse( $pre_trashed_replies );
		}

		// Loop through replies
		foreach ( (array) $pre_trashed_replies as $reply ) {
			wp_untrash_post( $reply );
		}
	}

	// Clear the trashed reply meta for the topic
	delete_post_meta( $topic_id, '_bbp_pre_trashed_replies' );
}

Top ↑

Changelog Changelog

Changelog
Version Description
2.6.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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