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( "[email protected]", "מגזין חדש", "התפרסם מגזין חדש!" );

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?


1 Answer 1


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.

  • doesn't work either :\
    – Dor Zuberi
    May 13, 2012 at 6:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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