WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.logging 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.

share|improve this question
Try die(var_dump(function_exists('wp_mail'))); instead of die('hi'); What does that give you? – s_ha_dum Feb 28 '13 at 19:36

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.