The first thing admin-ajax.php
does is define DOING_AJAX
. Then, it loads wp-load.php
. It does some other stuff, and the first thing it comes across that you have control over is wp-config.php
.
So if you want to stop all ajax, you can add to following to your wp-config.php
file.
if( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
wp_die( '0', 400 );
}
If you don’t have access to the wp-config
file, or just want to do it via a plugin, you can do that too. No need to add it to a hook since if it’s a request that doing ajax, it’s already defined.
/**
* Plugin Name: Stop Ajax
*/
if( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
wp_die( '0', 400 );
}
There will be side effects if you’re using plugins or themes that require ajax, so be careful.
Related Posts:
- AJAX request on the frontend always returns 0 if user is not admin
- How can I get logged in user’s session data from admin-ajax?
- Plugin: AJAX query external API to sync to tables
- WordPress is creating nonce as a logged in user but verifying it incorrectly
- admin-ajax.php returns 0 even when the post status code is 200 OK
- Can I use application/json content type in WordPress
- AJAX call not initializing for non-admins in WordPress
- Refresh HTML Page in Browser Automatically on Timer – Every 15 Min
- How to load wp_editor() through AJAX/jQuery
- How to get a unique nonce for each Ajax request?
- Open a Thickbox with content trough AJAX
- Is there a JavaScript API? How to access public and private data in JS?
- failed to load wp-admin/admin-ajax.php
- WP List Table custom quick edit box – post meta data missing and columns change on submit
- Are ‘wp_ajax’ and ‘wp_ajax_nopriv’ exclusive to authenticated and non-authenticated users?
- How to HTML5 FormData Ajax
- admin-ajax.php doesn’t work when using POST data and Axios
- Custom Form with Ajax
- How to process ajax requests correctly using ajax plugins
- How do I hook an Ajax request into a PHP callback?
- Gutenberg – how to correctly perform ajax request on backend
- get_template_part execute with ajax
- How to add WordPress nonces to ajax request
- How is it possible that the function of the test page works, but it does not go live?
- How declare Ajax functions ussing SHORTINIT
- jQuery Autocomplete not working with wp_localize_script
- Load custom formatted comment with AJAX: reply link isn’t rendered?
- Is there a way to optimize function that is used for returning data in an ajax-call?
- get_posts empty when called via Ajax
- admin-ajax.php mixed content
- WP-API and Basic Auth returning 403 on POST but not GET
- Is there a hook to process a backbone restful PUT request inside wordpress?
- Check if username exist with AJAX
- How to localized one js file for different actions?
- Help with shortcode in admin-ajax [closed]
- WooCommerce: Translation lost on AJAX call in Checkout page [closed]
- Why is this Ajax not working?
- How to add WP API and JS featured image attachment
- Using AJAX with Forms
- json encode not work in wordpress
- wordpress and add actions to button by coding
- Get Author Post on author.php with AJAX
- Admin-Ajax Error
- AJAX Call is Only Returning 100 Results from Query
- AJAX and -1 response
- How to make custom button link on the WordPress Admin Bar run by AJAX
- Admin AJAX doesn’t work in plugin admin page – Even though code is copied verbatim from WordPress Codex
- Ways to load admin-ajax faster without initializing all plugins?
- How to make registration form ajax?
- Specify ABSPATH in jQuery url
- 403 error When i send ajax request on WordPress website
- Ajax Call 400 Bad Request error with POST request but not with GET request
- While Ajax is working well, media upload isn’t showing the imagines
- How can I call an api before user login
- Problems with wordpress nonces in Ajax call
- Get post content and show it in a div
- Output multi-steps form results in same page
- why does not work ajax that add_action registered in wordpress
- How to get post from pure frontend AJAX (using only post ID)?
- Auto load subcategories content with ajax
- Multiple AJAX requests using the same ajax_object.ajaxurl
- Is there a better way to access transients using javascript
- Filter custom post types by custom field using AJAX
- How to perform a frontend HTTP call with AJAX when plugin save the new settings?
- Refresh loop of custom posts (div) after new post is published
- Use ajax request to load sidebar
- How to change request URL?
- Why the wp_localize_script() does not work correct in my case? ( /wp-admin/admin-ajax.php 400 (Bad Request) )
- Updating failed. The response is not a valid JSON response. specific to my browser when I include javascript in my html
- Automatically refresh div id every 15 seconds with code snippet from .php file
- Should wordpress nonce be placed in html form or in javascript file
- Ajax call returning 0 in page template
- If I leave out the wp_die() in the testiframe function I get the ‘0’ appended to my output. If I put it in, the page w/ iframe linked to it crashes
- how to make sure js is enabled before executing php function
- How to run an ajax call in elementor editor
- 400 Bad Request – Post to admin-ajax.php
- jQuery AJAX url wit variable
- How to pass array from jQuery to PHP with AJAX in WordPress?
- Using existing ajax data that is loaded into page
- How to force the admin-ajax.php file to load over HTTPS?
- Unable to ajax request with meta_query
- get_body_class() in ajax envrionment
- Ajax WordPress pass post URLs
- Should I edit a user meta field with PUT, PATCH, or POST and WP::Editable
- AJAX action returning empty posts array?
- Infinite Scroll
- Cannot add multiple single images at once
- How to send custom variable in Media Uploader ajax request?
- WordPress Ajax JSON success return no being recognized
- WordPress page content only in fancybox except direct click
- Ajax takes 10x as long as it should/could
- How to use AJAX to check if user is still logged-in?
- Ajax navigation and scripts loaded only on certain pages
- Closing ajax function file with die() causes error and empty page
- How to load wordpress sidebar using AJAX [duplicate]
- using Ajax: call to undefined function get_option
- How To Pass Ajax Value to PHP Query?
- ajax for visitors wordpress
- PHP cookie not set within AJAX call
- WordPress Ajax send response on every iteration of a loop