# supportcandy/2.3.1/includes/rest_api/v1/delete_ticket.php

SupportCandy – AI Customer Support Ticket System &amp; Live Chatbot Agent, version 2.3.1. 45 lines.

- Page: https://pluginprobe.com/plugins/supportcandy/2.3.1/code/includes/rest_api/v1/delete_ticket.php
- Raw: https://pluginprobe.com/plugins/supportcandy/2.3.1/raw/includes/rest_api/v1/delete_ticket.php
- Modified: 2022-07-21T08:20:56+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/supportcandy/2.3.1/code/includes/rest_api/v1/delete_ticket.php#L10-L20`.

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

global $wpscfunction;


$params    = $request->get_params();
$ticket_id = isset( $params['id'] ) ? $params['id'] : 0;

$response = array();

if ($wpscfunction->is_ticket($ticket_id)) {
  
    if($wpscfunction->has_permission('delete_ticket',$ticket_id)){
    	 $wpscfunction->delete_tickets($ticket_id);
       $response  = array(
         'ticket_deleted',
         'Ticket id '. $ticket_id .' is deleted successfully',
         array(
             'status' => 200,
         )
       );
    }else{
      $response  = array(
        'unauthorized',
        'You do not have permission to delete this ticket.',
        array(
            'status' => 404,
        )
      );
    }

} else {
    
    $response = new WP_Error(
        'not_found',
        'Ticket not found for id '.$ticket_id,
        array(
            'status' => 404,
        )
    );

}
```
