I know this has come up a number of times but it is driving me nuts. I've spend hours trying to debug it.
My AJAX isn't working for non-logged in users.
Here's me action:
add_action('wp_ajax_nopriv_ah_update', array($tracker, 'update_tracking'), "1");
add_action('wp_ajax_ah_update', array($tracker, 'update_tracking'), "1");
I've placed them inbetween is_admin and out of it. I've taken the server side code out of the class and put it in its own function. But nothing works.
I should state that it works fine for all logged-in users
I've done a var_dump() on $_GET['request'] and it all looked fine.
if ( !empty( $_REQUEST['action'] ) )
do_action( 'wp_ajax_nopriv_' . $_REQUEST['action'] );
die('-1');
If I change the admin-ajax.php code to this it works fine:
if ( !empty( $_REQUEST['action'] ) ) {
do_action( 'wp_ajax_nopriv_' . $_REQUEST['action'] );
} else {
die('-1');
}
I'm a total loss as to what is causing this to happen.
Perhaps there is something else in the script that is blocking no-logged in user access, but I can't see it.
die()
? If your code doesn't, then WordPress will fire the action hook as expected and still calldie('-1')
afterwards.