Use check_ajax_referer:
https://codex.wordpress.org/Function_Reference/check_ajax_referer
//Check nonce
if ( !check_ajax_referer( 'nonce-action-name', '_wpnonce', false ) ){
echo __('Ajax Security Check', 'yourtextdomain');
die();
}
Related Posts:
- How to get a unique nonce for each Ajax request?
- Nonces and Cache
- Is it safe to assume that a nonce may be validated more than once?
- Multiple ajax nonce requests
- Using Nonces for AJAX that only retrieves data
- How to verify nonce from Bulk/Quick Edit in save_post?
- How to add WordPress nonces to ajax request
- Nonces and Ajax request to REST API and verification
- Ajax function returns -1
- Serving nonces through AJAX is not refreshing nonce, returning 403 error
- wp_verify_nonce always returns false when logged in as admin
- ajax and nonce when JavaScript is in a seperate file
- wp_verify_nonce doesn’t return true on server when it matches the nonce
- AJAX requests broken due to HTTPS for wp-admin
- Nonces, AJAX, script variables & security in WordPress
- Why does WordPress Heartbeat login not refresh the nonces?
- wp-admin AJAX with Fetch API is done without user
- How do I check if AJAX nonces are implemented correctly?
- How to check an ajax nonce in PHP
- Can a wp_nonce created from domain 1 to be verified on domain 2?
- how to send Ajax request in wordpress backend
- Identical wp_rest nonce returned from rest_api
- WP Admin AJAX Security – using POST to include a relative URL
- wp_create_nonce() in REST API makes user->ID zero
- ajax nonce verification failing
- SSO autologin WordPress + Ajax
- Nonce fails on ajax save
- Unable to successfully verify nonce
- Cache plugins and ajax nonce verification
- Why does check_ajax_referer give a 403 error on https websites?
- WordPress is creating nonce as a logged in user but verifying it incorrectly
- javascript ajax and nonce
- How to check nonce lifetime value of plugins?
- Using nonce when loading posts with AJAX
- Should wordpress nonce be placed in html form or in javascript file
- wp_verify_nonce not working on the mobile device
- How do I mitigate replay attacks when talking about actions that shouldn’t happen twice?
- AJAX form not working, still reloads on submit
- Ajax Security regarding user priviliges and nonces
- How to use nonces for frontend AJAX voting if the page gets cached?
- WordPress wp_localize_script nonce and ajax URL
- Ajax in a settings page (update_option is undefined)
- Nonces can be reused multiple times? Bug / Security issue?
- gettext does not translate when called in ajax
- Execute one AJAX request after another AJAX request finished
- Ajax and autocomplete
- admin-ajax.php vs Custom Page Template for Ajax Requests
- Load tinyMCE / wp_editor() via AJAX [duplicate]
- How to correctly load wordpress in a non WP script for AJAX request
- Why is admin ajax reloading my page
- Plupload in metabox – AJAX action not working in Class
- CPU usage: AJAX and Heartbeat API on admin pages
- Can part of my WordPress website be headless?
- Extending wp JavaScript base class to make a post request to a custom REST endpoint
- Why would admin-ajax.php redirect to the home page for logged out users?
- wp_localize_script escaping my url – fix or alternative
- Admin Ajax and HTML5 Formdata
- Implementing an AJAX POST API call in wordpress
- WordPress ajax problem need wordpress expert?
- Ajax WordPress Login needs to be stayed in current page Url without redirecting
- wp_ajax function did not call
- Loading comments in ajax – comment-reply function missing $args
- Why ajax doesn’t work on certain wordpress hooks and reload the page instead?
- Woocommerce update product price via AJAX
- How do I query posts by a sub value with the API?
- Popup or admin/update notice on post/page edit screen without page refresh
- Enqueue script in plugin is not working
- Single page site + pushState?
- Ajax call does not work for this simple code
- WordPress ajax call returns a zero though die()
- wp_update_post onclick button using ajax
- Redirect after saving form; and yet use wp_die()
- ajaxt returning object object [closed]
- Load more posts (Ajax) in tabbed sidebar on single.php
- Something strange with ajax
- admin-ajax.php returns 0 even when the post status code is 200 OK
- Why is the file not uploading to the server?
- Get localize of a loaded javascript
- Merge PDF files from post custom fields(ACF) into one PDF file and respond back the created PDF file, WordPress(AJAX Request)
- REST public POST giving 403 forbidden nginx
- Query data after an Ajax insert
- Content including hooks inside wp-settings.php are being called twice in WordPress
- Problem when sending file via ajax
- Can’t GET Variable from AJAX URL
- JS global variable doesn’t update
- 404 error custom post type rest api
- How to update cart total after AJAX success
- Change button text after ajax db update
- Jquery wrap permalink in a data-attribute?
- Load .php file into div using ajax
- Native WordPress Video Shortcode Not Working After Post is Loaded via Ajax
- Using AJAX for dynamic settings pages
- Speeding up admin-ajax.php
- admin ajax is not working for non logged in users
- wp_localize_script not create variable in head section
- AJAX admin Internal 500 error Failed to Upload
- Class property not visible inside ajax callback function?
- $wpdb Ajax not redirecting to main page
- wordpress ajax bad request 400
- Custom WP rest api endpoint only working on non https?