bbp_open_topic( int $topic_id )

Opens a topic

Description

Parameters

$topic_id

(Required) Topic id

Return

(mixed) False or WP_Error on failure, topic id on success

Source

File: bp-forums/topics/functions.php

2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
function bbp_open_topic( $topic_id = 0 ) {
 
    // Get topic
    $topic = bbp_get_topic( $topic_id );
    if ( empty( $topic ) )
        return $topic;
 
    // Bail if already open
    if ( bbp_get_closed_status_id() !== $topic->post_status )
        return false;
 
    // Execute pre open code
    do_action( 'bbp_open_topic', $topic_id );
 
    // Get previous status
    $topic_status       = get_post_meta( $topic_id, '_bbp_status', true );
 
    // Set previous status
    $topic->post_status = $topic_status;
 
    // Remove old status meta
    delete_post_meta( $topic_id, '_bbp_status' );
 
    // No revisions
    remove_action( 'pre_post_update', 'wp_save_post_revision' );
 
    // Update topic
    $topic_id = wp_update_post( $topic );
 
    // Execute post open code
    do_action( 'bbp_opened_topic', $topic_id );
 
    // Return topic_id
    return $topic_id;
}

Changelog

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