I have two actions. One is after saving a post, so add_action('save_post', 'on_any_post');
I have a second action triggered via AJAX, so
add_action( 'wp_ajax_nopriv_saveTaskPriority', 'saveTaskPriority' );
add_action( 'wp_ajax_saveTaskPriority', 'saveTaskPriority' );
In both on_any_post
and saveTaskPriority
, I have the following code:
$to = array('foo@bar.com');
$subject = 'foo';
$body = 'bar';
wp_mail($to, $subject, $body);
The only difference is, in the ajax function, I have die('hi');
at the end.
I KNOW the ajax method is being called, because I am returning data and console.log
ging it. (Meaning I see ‘hi’ in the response of the POST in chrome developer tools)
I get the email from the save_post
action, but not the ajax action. What gives?
EDIT:
If I use straight up mail()
in the ajax function, it works.