bbp_unspam_topic( int $topic_id )

Unspams a topic


Description Description


Parameters Parameters

$topic_id

(Required) Topic id


Top ↑

Return Return

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


Top ↑

Source Source

File: includes/topics/functions.php

function bbp_unspam_topic( $topic_id = 0 ) {

	// Get the topic
	$topic = bbp_get_topic( $topic_id );
	if ( empty( $topic ) ) {
		return $topic;
	}

	// Bail if already not spam
	if ( bbp_get_spam_status_id() !== $topic->post_status ) {
		return false;
	}

	// Execute pre unspam code
	do_action( 'bbp_unspam_topic', $topic_id );

	// Get pre spam status
	$topic_status = get_post_meta( $topic_id, '_bbp_spam_meta_status', true );

	// If no previous status, default to publish
	if ( empty( $topic_status ) ) {
		$topic_status = bbp_get_public_status_id();
	}

	// Set post status to pre spam
	$topic->post_status = $topic_status;
	$topic->tax_input   = bbp_unspam_topic_tags( $topic_id );

	// Delete pre spam meta
	delete_post_meta( $topic_id, '_bbp_spam_meta_status' );

	// No revisions
	remove_action( 'pre_post_update', 'wp_save_post_revision' );

	// Update the topic
	$topic_id = wp_update_post( $topic );

	// Execute post unspam code
	do_action( 'bbp_unspammed_topic', $topic_id );

	// Return topic_id
	return $topic_id;
}

Top ↑

Changelog Changelog

Changelog
Version Description
2.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.