bbp_spam_topic( int $topic_id )
Marks a topic as spam
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_spam_topic( $topic_id = 0 ) { // Get the topic $topic = bbp_get_topic( $topic_id ); if ( empty( $topic ) ) { return $topic; } // Get new status $status = bbp_get_spam_status_id(); // Bail if topic is spam if ( $status === $topic->post_status ) { return false; } // Add the original post status as post meta for future restoration add_post_meta( $topic_id, '_bbp_spam_meta_status', $topic->post_status ); // Execute pre spam code do_action( 'bbp_spam_topic', $topic_id ); // Set post status to spam $topic->post_status = $status; // Empty the topic of its tags $topic->tax_input = bbp_spam_topic_tags( $topic_id ); // No revisions remove_action( 'pre_post_update', 'wp_save_post_revision' ); // Update the topic $topic_id = wp_update_post( $topic ); // Execute post spam code do_action( 'bbp_spammed_topic', $topic_id ); // Return topic_id return $topic_id; }
Changelog Changelog
Version | Description |
---|---|
2.0.0 | Introduced. |