# supportcandy/2.3.1/includes/admin/email_notifications/delete_ticket_notification.php

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

- Page: https://pluginprobe.com/plugins/supportcandy/2.3.1/code/includes/admin/email_notifications/delete_ticket_notification.php
- Raw: https://pluginprobe.com/plugins/supportcandy/2.3.1/raw/includes/admin/email_notifications/delete_ticket_notification.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/admin/email_notifications/delete_ticket_notification.php#L10-L20`.

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

global $current_user, $wpscfunction;

if (
	check_ajax_referer('delete_ticket_notification', '_ajax_nonce', false) != 1
) wp_send_json_error('Unauthorised request!', 400);

if (!($current_user->ID && $current_user->has_cap('manage_options'))) {
	exit;
}

$term_id = isset($_POST) && isset($_POST['term_id']) ? intval($_POST['term_id']) : 0;
if(!$term_id) die();

$email_subject = get_option('wpsc_email_notification_subject');
unset($email_subject['email_subject_' . $term_id]);
update_option('wpsc_email_notification_subject', $email_subject);

$email_body = get_option('wpsc_email_notification_body');
unset($email_body['email_body_' . $term_id]);
update_option('wpsc_email_notification_body', $email_body);

$response = wp_delete_term( $term_id,'wpsc_en');

if(!is_wp_error($response)){
  
  do_action('wpsc_delete_ticket_notification',$term_id);
  echo '{ "sucess_status":"1","messege":"'.__('Email Notification delete successfull.','supportcandy').'" }';
  
} else {
  echo '{ "sucess_status":"0","messege":"'.__('An error occured while deleting email notification.','supportcandy').'" }';
}

```
