• I wrote a small bit of code to send an email to the admin when a pending custom post type is submitted for review (pending status). It works fine.

    But when I try to notify the user that their post has been published (when the status changes from pending to publish) the email isn’t generated for them? Is there anything wrong with the following:

    function notify_submitter() {
     global $post;
     $custom = get_post($post->ID);
     $author = get_userdata($custom->post_author);
     $author_email = $author->user_email;
     $message = "message here...";
     $headers = 'From: me <[email protected]>' . "\r\n";
       wp_mail($author_email, "subject here...", $message, $headers);
    }
    add_action('pending_to_publish_[custom_post_type]', 'notify_submitter');
Viewing 1 replies (of 1 total)
  • Thread Starter Jacorre

    (@jacorre)

    I did further testing with this and found that I believe it’s an issue with post transitions with custom post types. If I use publish_[custom_post_type] it works fine, but I don’t want follow up emails if I update the custom post type.

    So I want to use pending_to_publish_[custom_post_type] so that it only applies when the status transitions that one time. But unfortunately it’s not working with the post transition. I also tried new_to_publish_[custom_post_type] and still doesn’t work.

Viewing 1 replies (of 1 total)
  • The topic ‘Post Status Transitions and wp_mail’ is closed to new replies.