bbp_open_topic( int $topic_id )
Opens a topic
Description Description
Parameters Parameters
- $topic_id
-
(Required) Topic id
Return Return
(mixed) False or WP_Error on failure, topic id on success
Source Source
File: includes/topics/functions.php
function bbp_open_topic( $topic_id = 0 ) { // Get topic $topic = bbp_get_topic( $topic_id ); if ( empty( $topic ) ) { return $topic; } // Bail if not closed 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 ); // If no previous status, default to publish if ( empty( $topic_status ) ) { $topic_status = bbp_get_public_status_id(); } // Set previous status $topic->post_status = $topic_status; // Remove old status meta delete_post_meta( $topic_id, '_bbp_status' ); // Toggle revisions off as we are not altering content if ( post_type_supports( bbp_get_topic_post_type(), 'revisions' ) ) { $revisions_removed = true; remove_post_type_support( bbp_get_topic_post_type(), 'revisions' ); } // Update topic $topic_id = wp_update_post( $topic ); // Toggle revisions back on if ( true === $revisions_removed ) { $revisions_removed = false; add_post_type_support( bbp_get_topic_post_type(), 'revisions' ); } // Execute post open code do_action( 'bbp_opened_topic', $topic_id ); // Return topic_id return $topic_id; }
Changelog Changelog
Version | Description |
---|---|
2.0.0 | Introduced. |