There is a plugin that is loading ajax actions like so:

add_action( 'wp_ajax_nopriv_func_name', array( &$this, 'func_name' ) );
add_action( 'wp_ajax_get_func_name', array( &$this, 'func_name' ) );

I want to remove them in my theme so I am doing:


But they are still there. I am definitely doing this after they have been added. I brought $wp_filter into scope and saw they were definitely set before my code and unset after.

It looks though like wordpress when you add ajax actions works a little differently. I think the actual action is stored somewhere else and I am just removing an alias to it as when I look inside the $wp_filter array the function name is like 4823746378642374682746func_name.

I am not sure where it is referencing or what the procedure is for removing it.

Can anyone shed some light on this for me?


I think the numbers are because the class object is being passed, I guess its a hash of the class.


This appears to be a bug/inconsistency. I did the following test:

    add_action('wp_ajax_nopriv_ajax_test', array(&$this, 'ajax_test'));
    add_action('wp_ajax_ajax_test', array(&$this, 'ajax_test'));

the ajax_test function is still accessible from javascript even though it was removed immediately after adding.

Does anyone know where this is being stored?


I found the code responsible in admin-ajax.php

do_action( 'wp_ajax_' . $_REQUEST['action'] );

The really weird thing I can't get my head around is that the ajax request returns before this code is hit. So it seems this code is just for doing associated actions and not returning the ajax request.

  • What hook are you using to remove the action? It could be that you're hook isn't loaded when the AJAX is called. Commented May 18, 2015 at 1:06
  • Yeah, it was a combination of this and a missing wp_die() confusing things.
    – Guerrilla
    Commented May 18, 2015 at 1:24

2 Answers 2


The main issue I was having is that when an ajax request hits not all hooks are being loaded.

I used this code:

$return = array();
foreach( $GLOBALS['wp_actions'] as $action => $count )
    $return["message"] .= $action . ", ";

This showed me the hooks that were running before and I got it to work.

I think removing ajax actions on "wp_loaded" is probably best as it seems to be the last hook before admin ajax is hit. If you remove on "admin_init" then you miss the check at the top of the file although that may mean you miss some so maybe it is better to do on admin_init.


I am guessing that this issue is because the wp_ajax action in the plugin is added after the remove_actions in the functions.php.

U can fix the above issue by using the wp_loaded action since it is executed after all the plugins are loaded

function after_wp_is_loaded(){
try {


//catch exception
catch(Exception $e) {
  echo 'Message: ' .$e->getMessage();
  • 1
    OP said that wasn't the issue, and explains what the issue was in their own answer. But you're right that wp_loaded is the correct hook to use. Would you expect remove_all_actions to throw?
    – Rup
    Commented Jul 30, 2021 at 8:16

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.