# taskbuilder/6.0.6/includes/admin/tasks/wppm_set_delete_task.php

Taskbuilder – Project Management &amp; Task Management Tool With Kanban Board, version 6.0.6. 19 lines.

- Page: https://pluginprobe.com/plugins/taskbuilder/6.0.6/code/includes/admin/tasks/wppm_set_delete_task.php
- Raw: https://pluginprobe.com/plugins/taskbuilder/6.0.6/raw/includes/admin/tasks/wppm_set_delete_task.php
- Modified: 2026-09-17T18:30:20+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/taskbuilder/6.0.6/code/includes/admin/tasks/wppm_set_delete_task.php#L10-L20`.

```php
<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly
}

global $current_user, $wppmfunction ,$wpdb;
if ( check_ajax_referer( 'wppm_set_delete_task', '_ajax_nonce', false ) != 1 ) {
	wp_send_json_error( 'Unauthorised request!', 401 );
}
$task_id  = isset($_POST['task_id']) ? intval(sanitize_text_field(wp_unslash($_POST['task_id']))) : 0 ;

$task_data = $wppmfunction->get_task($task_id);
$project_data = $wppmfunction->get_project($task_data['project']);
$wppm_current_user_capability = get_user_meta( $current_user->ID, 'wppm_capability', true );
if(!(($current_user->ID && $current_user->has_cap('manage_options')) || ($wppmfunction->has_permission('delete_task',$task_id)) || $wppm_current_user_capability == 'wppm_admin'|| $project_data['created_by']==$current_user->ID )){
    exit;
}
// Deletes the task's own attachments/checklists/comments, and cascades to any subtasks.
WPPM_Functions::delete_task_and_children($task_id);
```
