check_ajax_referer
Action HookDescription
Fires once the Ajax request has been validated or not.Hook Information
File Location |
wp-includes/pluggable.php
View on GitHub
|
Hook Type | Action |
Line Number | 1358 |
Hook Parameters
Type | Name | Description |
---|---|---|
string
|
$action
|
The Ajax nonce action. |
false|int
|
$result
|
False if the nonce is invalid, 1 if the nonce is valid and generated between 0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago. |
Usage Examples
Basic Usage
<?php
// Hook into check_ajax_referer
add_action('check_ajax_referer', 'my_custom_function', 10, 2);
function my_custom_function($action, $result) {
// Your custom code here
}
Source Code Context
wp-includes/pluggable.php:1358
- How this hook is used in WordPress core
<?php
1353 *
1354 * @param string $action The Ajax nonce action.
1355 * @param false|int $result False if the nonce is invalid, 1 if the nonce is valid and generated between
1356 * 0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
1357 */
1358 do_action( 'check_ajax_referer', $action, $result );
1359
1360 if ( $stop && false === $result ) {
1361 if ( wp_doing_ajax() ) {
1362 wp_die( -1, 403 );
1363 } else {
PHP Documentation
<?php
/**
* Fires once the Ajax request has been validated or not.
*
* @since 2.1.0
*
* @param string $action The Ajax nonce action.
* @param false|int $result False if the nonce is invalid, 1 if the nonce is valid and generated between
* 0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
*/
Quick Info
- Hook Type: Action
- Parameters: 2
- File: wp-includes/pluggable.php
Related Hooks
Related hooks will be displayed here in future updates.