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

2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
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.