I'm writing a plugin that calls the output of another plugin's ajax, which is set-up at wp_ajax_
I would have called the functions directly, but limitations in the plugin make that a non-option.
To make it clear, this is what's happening:
- User selects an action, then hits apply
- My plugin function is called in admin-ajax.php (via the
wp_ajax_
hook) - The plugin function creates a nonced url like this:
$url = wp_nonce_url( admin_url( 'admin-ajax.php?action=plugin_action&post_id=' . $post_id), 'plugin_action' );
- then I call that url with
wp_remote_get
output is 0
.
Now the strange thing: instead of calling the url with wp_remote_get
I echoed it, then copy pasted it in my browser and it gave me the correct output. (so it's not a matter of a missing die()
!)
I've also tried putting my own function in edit.php (using the load-
hook) instead of admin-ajax.php too, but the result was the same (0).
Now the codex shows that the load-
hook is executed before wp_ajax
, so that's expected behaviour (the action is not added yet) but even in wp_ajax with a priority of 99 I get 0
.
Any ideas on what's going on? Could it be that the action is not added yet when I call it directly from admin-ajax.php? If so, is there a better place to put my own action? (one that fires after wp_ajax)