I figured it out. Simply, in my request, under data
, I added
"nonce" : "<?php echo wp_create_nonce( 'refresh_my_plugin' ); ?>"
then to verify
if (isset($_POST['refresh_my_plugin']))
if ( wp_verify_nonce( $_POST['nonce'], 'refresh_my_plugin' ) )
refresh_my_plugin();
With incorrect wp_verify_nonce
, I instead get a 403, which is reflected on the button with the error
handler.
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?
- 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
- Nonce doesn’t validate in nopriv call
- 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
- ASP.NET MVC controller actions that return JSON or partial html
- How to check if I am in admin-ajax.php?
- Ajax in a settings page (update_option is undefined)
- Nonces can be reused multiple times? Bug / Security issue?
- admin-ajax.php vs Custom Page Template for Ajax Requests
- AJAX Implementation
- how to use ajax in plugin admin area?
- Load page content with AJAX using Fancybox?
- edit-comments.php comment_row_actions ajax problem
- jQuery UI Autocomplete showing all results
- How to Access custom database content with AJAX onClick refresh of div inside member-only WordPress page?
- Ajaxing in functions.php
- add_action and Ajax
- Embedded Twitter feed won’t render nicely when loaded via Ajax
- Enqueue script dinamically
- Most performant way of fetching remote API data?
- Admin-ajax responds with 0 due to empty $_REQUEST
- Using ajax with wordpress
- Using foreach inside an ajax function
- Ajax Modal Flickers When Opened Multiple Times
- Ajax image upload with media_handle_upload and form.js
- Caching-Plugins and Ajax-Page-Parts
- Ajax loading duplicate post
- WordPress Ajax POST Error 403 admin-ajax.php
- How do I detect in which page ajax_query_attachments_args is loaded?
- Ajax post returning full html page as response
- Which allowed API hooks work to add wp_ajax action?
- Why ajax doesn’t work on certain wordpress hooks?
- Ajax store response json in variables
- Performance optimization of tree like structure
- WordPress search results with Ajax, get_post_type() not working
- How can I set cookies on both secure and non-secure origins at the same time?
- Variable Products Being Added to Cart with AJAX on Shop and Category Pages
- Is it secure to use admin-ajax.php in front?
- Best way to use ajax front-end?
- merge wp rest api query to get posts per category does not work
- use jQuery.load() to include a php file in a div, wp_query() is part of php file
- Load more posts in the same category – Ajax + Timber
- admin-ajax.php returns 0 even when the post status code is 200 OK
- is there’s a way to get the next page content generated by page break block with ajax call?
- Merge PDF files from post custom fields(ACF) into one PDF file and respond back the created PDF file, WordPress(AJAX Request)
- Passing value from select form with Ajax not working
- Sending email through Ajax without page refresh hangs on admin_ajax.php
- Is there a public ajax endpoint?
- Why Ajax Doesn’t Work?
- How can i do public ajax call?
- How to prevent multiple post with same meta value being created simultaneously in WordPress (with ajax)
- Can’t GET Variable from AJAX URL
- JS global variable doesn’t update
- How to update cart total after AJAX success
- How to implement AJAX within a class storing shortcode atts as class variables
- Jquery wrap permalink in a data-attribute?
- (Frontend AJAX) get post data WITH image thumbnail?
- Load .php file into div using ajax
- AJAX Post from same domain to a wordpress page
- Add Ajax loaded posts to existing posts
- Using AJAX for dynamic settings pages
- ‘Dehighlighting’ navigation once clicked
- Run PHPMailer function after ajax function completes that adds row to custom table