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
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
| 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.