Okay, so I found a working solution which is as simple as I thought the whole process should be. The confusing WordPress codex made things harder really.
The creation and naming of the nonce is as simple as:
wp_create_nonce( 'example' );
This is passed though AJAX and localisation of the script to the PHP.
Then during a $_POST verification; all that is needed is to pass the post name as the second parameter in the verification function. eg:
check_ajax_referer( 'example', 'nonce')
nonce
is the name of the $_POST identifier eg:
$_POST['nonce']
Somehow it was really hard to understand this through the codex, and other examples found through the web. I hope this explanation can help someone else struggling with the codex and nonces.
Related Posts:
- ajax and nonce when JavaScript is in a seperate file
- Nonces, AJAX, script variables & security in WordPress
- wp-admin AJAX with Fetch API is done without user
- AJAX form not working, still reloads on submit
- JavaScript implementation of Gzip
- Nonces and Cache
- Is it safe to assume that a nonce may be validated more than once?
- Multiple ajax nonce requests
- How to properly use wp.ajax.post?
- Using Nonces for AJAX that only retrieves data
- How to verify nonce from Bulk/Quick Edit in save_post?
- Refused to execute script from ‘***’ because its MIME type (‘text/html’) is not executable, and strict MIME type checking is enabled
- Nonces and Ajax request to REST API and verification
- Dynamically changing navigation links (next and previous) via AJAX
- Ajax function returns -1
- Serving nonces through AJAX is not refreshing nonce, returning 403 error
- Quick Edit: Selected Custom Taxonomy Not Refreshing After Save
- Vue.js + AJAX Shortcode
- Turn jQuery.ajax() request into XMLHttpRequest (vanilla JavaScript)
- wp_verify_nonce always returns false when logged in as admin
- fetching via fetch/ajax gutenberg block data from third party
- admin-ajax.php HTTP400: BAD REQUEST – The request could not be processed by the server due to invalid syntax
- AJAX issue – Uncaught SyntaxError when processing Zip File
- wp_verify_nonce doesn’t return true on server when it matches the nonce
- WordPress AJAX Call Not Return Result
- AJAX requests broken due to HTTPS for wp-admin
- Extending wp JavaScript base class to make a post request to a custom REST endpoint
- Why does WordPress Heartbeat login not refresh the nonces?
- How do I check if AJAX nonces are implemented correctly?
- Admin Ajax and HTML5 Formdata
- How to check an ajax nonce in PHP
- Populating content dynamically via AJAX and Advanced Custom Fields [closed]
- Help with AJAX front end comment moderation
- Can a wp_nonce created from domain 1 to be verified on domain 2?
- Woocommerce Ajax Add cart not working
- 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
- Ajax Modal Flickers When Opened Multiple Times
- wp_create_nonce() in REST API makes user->ID zero
- ajax nonce verification failing
- Load JavaScript from a post that’s loading into Fancybox via ajax
- splitting the URL using jQuery
- SSO autologin WordPress + Ajax
- AJAX Load more on CPT returning random posts
- Refresh Markercluster after ajax call
- Making an ajax request from a different domain
- Performance optimization of tree like structure
- How do I query posts by a sub value with the API?
- Radio buttons live refresh in the customizer
- Nonce fails on ajax save
- Gravity Forms closes my popup on Validation Error [closed]
- Why is wp_localize_script returning false?
- Unable to successfully verify nonce
- Cache plugins and ajax nonce verification
- Nonce doesn’t validate in nopriv call
- Using admin-ajax prevents regular php form submission
- 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
- wp_mail doesn’t work when logged in?
- Hide Load more Ajax button if there is no more users to load or less than the number?
- How to disable drag-and-drop upload function in Media Library?
- How to check nonce lifetime value of plugins?
- Making POST request with AJAX returns a 400 error (without jQuery)
- Run javascript upon successfully set featured image
- admin-ajax.php (aborted) error when using jQuery.get
- Replace link with form to pass variables to javascript / ajax
- Ajax page load without reload
- Load page HTML content through AJAX
- How to display contact form 7 form in vanilla js without jquery in frontend
- Get uploaded attachment width & height and attachment ID after upload them
- Get localize of a loaded javascript
- Uncaught TypeError: Cannot read properties of undefined (reading ‘message’) [closed]
- Refresh checkout fields on add to cart with order bump
- Refresh Gutenberg with JS for it show updated post
- How to Object.freeze wp_localize_script
- How to pass value from ajax to php in no conflict mode?
- ERROR while passing data from JS to PHP via AJAX
- Ajax sometimes work and sometimes just don’t work
- wp_verify_nonce not working on the mobile device
- React to AJAX adding to the page
- Download doccument on server rather than clients browser
- Javascript output now showing in custom widget
- Ajax call on class returns old data
- Ajax show custom post data form & script
- Create a post with REST API and adding a category
- Get post details with pure javascript ajax
- Jquery wrap permalink in a data-attribute?
- Ajax Security regarding user priviliges and nonces
- Session variables lost during Ajax calls – WordPress – Sage Starter Theme
- How to use nonces for frontend AJAX voting if the page gets cached?
- ‘Dehighlighting’ navigation once clicked
- Bad Request when adding new post via ajax form
- AJAX admin Internal 500 error Failed to Upload
- WordPress wp_localize_script nonce and ajax URL
- Running js in html code with same content
- How to get current_user_id from wordpress in node js?
- AJAX call not initializing for non-admins in WordPress
- Escaping admin_url output being passed to js (esc_js vs esc_url)
- How to submit a button automatically after every scheduled hours?