# supportcandy/2.3.1/includes/admin/settings/set_rest_api_settings.php

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

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

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

global $current_user;

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

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

// Allow Rest API
$wpsc_rest_api = isset($_POST) && isset($_POST['wpsc_rest_api']) ? intval($_POST['wpsc_rest_api']) : 0;
update_option('wpsc_rest_api',$wpsc_rest_api);

// secret key
$wpsc_rest_api_secret_key = isset($_POST) && isset($_POST['wpsc_rest_api_secret_key']) ? sanitize_text_field($_POST['wpsc_rest_api_secret_key']) : '';
update_option('wpsc_rest_api_secret_key',$wpsc_rest_api_secret_key);

do_action('wpsc_set_rest_api_settings');

echo '{ "sucess_status":"1","messege":"'.__('Settings saved.','supportcandy').'" }';
```
