bbp_untrash_forum_topics( int $forum_id )

Trash all topics inside a forum

Description

Parameters

$forum_id

(Required)

Return

(If) forum is not valid

Source

File: bp-forums/forums/functions.php

function bbp_untrash_forum_topics( $forum_id = 0 ) {

	// Validate forum ID
	$forum_id = bbp_get_forum_id( $forum_id );

	if ( empty( $forum_id ) )
		return;

	// Get the topics that were not previously trashed
	$pre_trashed_topics = get_post_meta( $forum_id, '_bbp_pre_trashed_topics', true );

	// There are topics to untrash
	if ( !empty( $pre_trashed_topics ) ) {

		// Maybe reverse the trashed topics array
		if ( is_array( $pre_trashed_topics ) )
			$pre_trashed_topics = array_reverse( $pre_trashed_topics );

		// Loop through topics
		foreach ( (array) $pre_trashed_topics as $topic ) {
			wp_untrash_post( $topic );
		}
	}
}

Changelog

Changelog
Version Description
bbPress (r3668) 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.