If an AJAX function does not work properly, in most cases you forgot to allow Users with no or little privileges to access the function.
Adding the Callback Function is quite simple:
add_action('wp_ajax_my_action', 'my_action_callback');
Now you need to do the same thing for the “not-so-privileged” users:
add_action('wp_ajax_nopriv_my_action', 'my_action_callback');
With these two lines everything should work as expected.
Related Posts:
- jQuery: Performing synchronous AJAX requests
- Best way to end WordPress ajax request and why?
- Why use wp_send_json() over echo json_encode()?
- Why not register shortcodes if is_admin dashboard?
- How to pass data parameter to ajax action function handler
- Contact Form 7 Custom Post Action
- Update user meta using with ajax
- WordPress function that makes HTML safe to be sent via AJAX request
- admin-ajax.php returns 0. How do I debug it and fix it?
- How to properly use wp.ajax.post?
- Detecting post type within init action
- Basic question on passing variables to AJAX in WordPress
- jQuery Autocomplete in WordPress
- Metabox cloning via Admin Ajax call issue
- Change theme based on window size
- Serving nonces through AJAX is not refreshing nonce, returning 403 error
- help on wp_editor via ajax load [duplicate]
- Cannot update my options using wp_ajax
- ajax and nonce when JavaScript is in a seperate file
- Class WP_Rewrite not found
- Prevent wp_debug from polluting ajax within plugin
- How to localize inline script called with ajax
- Conditional Ajax inclusion
- Buddypress ajax problem after adding new groups sub nav [closed]
- Allow AJAX call to other roles than admin
- How to check username availability with ajax at registration
- submitting form via admin-ajax.php returns 0
- Help add ajax load more button
- Can a wp_nonce created from domain 1 to be verified on domain 2?
- admin-ajax.php slow, how to speed it up?
- How to use several wp_ajax_ functions for different queries?
- Three level taxonomy dropdown frontend
- I’m getting a 401 while calling the wp-json endpoint via ajax
- Unable to parse JSON response from wp_send_json_success [closed]
- How to solve “Updating failed” with 403 Error when trying to save a Site or Post in Gutenberg?
- Keep getting 400 Bad Request error when trying out AJAX on custom theme
- problem with WordPress ajax
- How to set post_id to 0 when you upload image via Add media button. (async-upload.php)
- How to make tabulator ajax call in wordpress?
- How would you update a frontend form with AJAX
- Updating User Meta with Array on Click of Button AJAX
- Why is on status span no search results?
- eventON plugin AJAX call triggers website crash
- Radio buttons live refresh in the customizer
- Stop auto load wp-admin admin-ajax.php
- wp_enqueue_script() doesn’t work with AJAX
- Dynamically add more fields/remove last field in a form
- Save & Reset button in theme-option with Ajax (without refresh)
- Ajax Request for both logged and non logged users
- Ajax Multi Response Problem
- Force redirect single.php to index
- Any plugin or Script to integrate ajax selection module into WordPress page
- Custom AJAX Endpoint not returning any result
- WordPress Heartbeat API cannot parse data
- how should i get json encoded data from wordpress ajax action page
- AJAX call broken after actualization
- WP_Ajax Hook doesn’t execute this PHP code
- How to include php-generated javascript?
- Serve a different theme based on window size
- custom autocomplete search
- javascript ajax and nonce
- Is it possible to determine whether a page is a page template by page_id in ajax call?
- Chained ajax call, second call returns 0
- How to create a form button that executes a function?
- How to stop being directed to admin.php after sending request to admin-ajax.php
- 200 return code on ‘POST /wp-admin/admin-ajax.php’ while NOT logged in
- Next Ajax call doesn’t work
- Ajax page load without reload
- need a confirmation text to appear on email submission
- Including ‘wp-load.php’ after another include() generates an error
- How to make pages that arent indexed for ajax applications
- Why does reCAPTCHA v3 return 0 ? In custom AJAX registration form
- admin-ajax.php 400 bad request
- WordPress Ajax Page Load to skip embedded iframe
- WordPress POST AJAX call, var_dump($_POST) NULL and AJAX response empty when inside ob_start
- Set cors header for ajax requests
- Simple AJAX code that refreshes every x seconds?
- How to keep scripts persistent during admin-ajax process when saving widget?
- Very weird bug: Ajax for non-admins
- Search function – problem with whole words
- WordPress 403 error on form submission with Ajax
- I am getting Admin-ajax.php 400 Error
- Ajax and get_template_part
- Ajax is not defined
- Get posts by category via ajax
- How to require files in a custom endpoint
- Adding pagination to Ajax Query
- WordPress 4.9.6 – IncludeMe & getAjax GET using wrong URL
- Create secondary Archive page format?
- check_admin_referer fails on new AJAX plugin uninstall with “Are you sure you want to do this?”
- How to populate data from JSON using AJAX in TypeScript? [closed]
- Weird admin-ajax.php problem
- Ajax contact form returnig 0
- Trying to send AJAX data to WordPress hook
- wp_enqueue_media problem
- Can’t update WP Editor after Ajax
- Update user meta using Ajax on front end?
- retrieving page content per AJAX [duplicate]
- Posting to loop.php file
- Can’t access data from database using AJAX