# Cách tạo action, nonce,check\_ajax\_referer trên đường dẫn (ok)

![](https://1113999984-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M84NwP_L_qEsBHOa2xo%2F-MSCSNQLseB0zdIs5pHz%2F-MSCVrEjufNC96jE4-hi%2FScreenshot_1.jpg?alt=media\&token=8f2aa9d3-9278-489e-8381-552707e7725d)

C:\xampp\htdocs\test\wp-content\plugins\plugin-name\admin\partials\form\_ct.php

```
<form method="post" action="<?php echo add_query_arg(array('action'=>$this->plugin_name . '_ajax_themes_save'),  admin_url('admin-ajax.php')) ?>">
    <input type="hidden" value="<?php echo wp_create_nonce($this->plugin_name . '_them_ajax'); ?>" name="<?php echo $this->plugin_name ?>_nonce"/>
    <?php $form = new WPF_Form($this->plugin_name,$this->version,$cpt_id); 
        $form->form();
    ?>
    <p class="submit">
        <button id="<?php echo $this->plugin_name ?>_submit" class="button button-primary"><?php _e('Save', 'wpf') ?></button>
    </p>
    <div id="<?php echo $this->plugin_name ?>_success_text" class="updated"></div>
	<div class="<?php echo $this->plugin_name ?>_wait"></div>
</form>
```

C:\xampp\htdocs\test\wp-content\plugins\themify-wc-product-filter\admin\class-wpf-admin.php

```
public function save_themplate(){
        check_ajax_referer($this->plugin_name .'_them_ajax', $this->plugin_name .'_nonce', true);
        $form = new WPF_Form($this->plugin_name,$this->version);
        $result = $form->save_themplate($_POST);
        if($result){
           echo  wp_json_encode($result);
        }
        wp_die();
    }
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://learnphp.gitbook.io/learnphp/wordpress-advand/cach-tao-action-nonce-tren-duong-dan-ok.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
