暂挂操作似乎未触发

时间:2013-10-15 作者:nathanaelphilip

我已将操作“draft\\u to\\u pending”设置为在自定义帖子类型上激发。我假设,当用户单击“Status»Edit”将其更改为“Pending”,然后单击“Save Pending”时,该操作应该会触发,但似乎不会触发。

这是我的代码:

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 <[email protected]>\\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 个回复
SO网友:Nicolai Grossherr

您可能没有涵盖所有正确的操作,请尝试添加这些操作:

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

结束

相关推荐