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'm developing a small plugin which will send email to users when a new magazine is published.

i made a post type name "magazine" on the theme functions.php. and i wrote a plugin for email subscriptions.


function newsletter_sendEmails($post_id)
    $post = get_post($post_id);

    if ($post->post_type == 'magazine')
        mail( "dor@zuberi.me", "מגזין חדש", "התפרסם מגזין חדש!" );

add_action('publish_post', 'newsletter_sendEmails');

but from some reason i don't get the email when i publish a new magazine, why is that?

share|improve this question
What happens if you use wp_mail() as you should? – toscho May 13 '12 at 12:49
i don't know that function... thanks... – Dor Zuberi Jun 23 '12 at 11:52

It's never fired since the hook you need is not publish_post but publish_magazine which is actually {$new_status}_{$post_type} hook. So try publish_magazine

update: also you don't need to use get_post since you the hook passes the $post object to the function as a second parameter. take a look at wp_transition_post_status()

and if that's not working then you have something else going wrong.

share|improve this answer
doesn't work either :\ – Dor Zuberi May 13 '12 at 6:46

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.