0

I have the action ‘draft_to_pending‘ set to fire on a custom post type. I assume that when the user clicks “Status » Edit” changes it to “Pending” and then clicks “Save Pending”, this action is suppose to fire, but it doesn’t seem to do so.

Here is my code:

add_action('draft_to_pending','notify_email_rejected',99);

function notify_email_rejected($post){

    $post_id = $post->ID;

    $is_rejected = get_post_meta($post_id,'rejected_listing',true);

    $owner_id = get_post_meta($post_id,'owner',true);
    $owner = get_userdata($owner_id);

    $to = $owner->user_email;

    $headers = "From: HayForSale <admin@hayforsale.com>\r\n";
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

    $subject = 'Your listing was rejected at HayForSale.com';

    $rejection = get_post_meta( $post_id, 'rejection_message', true );

    $message = 'some html';

    wp_mail($to, $subject, $message, $headers);
} 
1

You might not have all the right actions covered, try to add those:

add_action('new_to_pending', 'notify_email_rejected');
add_action('auto-draft_to_pending', 'notify_email_rejected');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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