Skip to main content
2 of 2
replaced http://wordpress.stackexchange.com/ with https://wordpress.stackexchange.com/

add_action('wp_ajax_[action name]', myfunction) problem

I'm having the exact same problem described in this post: add_action('wp_ajax_[action name]', myfunction) problem

I set add_action('wp_ajax_my_function_call','my_ajax_function'). If I print_r($wp_filter) immediately after this line, my action is in the $wp_filter array.

However, by the time I do my jQuery.post call to admin-ajax.php, my action has disappeared from $wp_filter. I verified this by adding this to line 354 of wp-includes/plugin.php:

if($tag=='wp_ajax_my_function_call') print_r($wp_filter);

According to user1567 in the above-cited post, "the problem was the loading order and the location of the add_action calls." Unfortunately this hasn't helped me track down the problem. I tried setting the priority of the add_action to 99 and to 1. Neither helped.

Any other ideas on what might be causing this situation, or at an explanation of why, in general, an action that was definitely in $wp_filter at one point would inexplicably disappear from it without even being triggered?