# bbp-core/2.5.1/includes/admin/menu/Delete_Topic.php

Forumax – AI Powered Advanced Community Forum Plugin, version 2.5.1. 42 lines.

- Page: https://pluginprobe.com/plugins/bbp-core/2.5.1/code/includes/admin/menu/Delete_Topic.php
- Raw: https://pluginprobe.com/plugins/bbp-core/2.5.1/raw/includes/admin/menu/Delete_Topic.php
- Modified: 2026-10-12T12:43:18+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/bbp-core/2.5.1/code/includes/admin/menu/Delete_Topic.php#L10-L20`.

```php
<?php
/**
 * Delete Topic functionality
 *
 * @package Forumax
 */

defined( 'ABSPATH' ) || exit;

// AJAX handler to delete a topic
add_action( 'wp_ajax_forumax_delete_topic', 'forumax_delete_topic' );

/**
 * Delete a topic and its replies.
 */
function forumax_delete_topic() {

	// Check the nonce
	check_ajax_referer( 'bbpc-admin-nonce', 'bbpc_nonce' );

	if ( ! current_user_can( 'manage_options' ) ) {
		wp_send_json_error( 'Unauthorized request.' );
	}

	$topic_id = ! empty( $_POST['topic_id'] ) ? absint( $_POST['topic_id'] ) : 0;
	if ( empty( $topic_id ) ) {
		wp_send_json_error( 'Topic ID cannot be empty.' );
	}

	if ( ! bbp_is_topic( $topic_id ) ) {
		wp_send_json_error( 'Invalid topic.' );
	}

	// bbPress trashes the topic's replies on wp_trash_post and restores them on untrash.
	if ( ! wp_trash_post( $topic_id ) ) {
		wp_send_json_error( 'Failed to delete the topic.' );
	}

	wp_send_json_success( 'Topic Deleted successfully.' );
	wp_die();
}

```
