Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

code:

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

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.

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

Your Answer

 
discard

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.