Is it possible to simply disable/stop admin-ajax.php from running?

Have searched WordPress Doc. Have searched Google. Have searched this forum. Found no answer.

Have also tried this, but it doesn't work:

function stop_ajax()
    define( 'DOING_AJAX', false );
add_action( 'admin_init', 'stop_ajax' );
  • What do you mean by "disable/stop admin-ajax.pl from running"? What should be done if such request is sent and it's disabled? Mar 14, 2018 at 23:04
  • It's not clear if you're referring to wordpress heartbeat, but in this case, there are some good tutorials around the web explaining how to disable or better, how to limit it. This one is a good starting point siteground.com/tutorials/wordpress/limit-heartbeat Mar 14, 2018 at 23:07

1 Answer 1


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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.