我做了一个自定义功能,所以当Posteta更新到特定值时,我发送自定义电子邮件使用wp_mail()
.
电子邮件发送成功,但同时创建了两个。
这里是我的代码:
function email_notification_by_status()
{
// Global Variable
$post_id = get_The_ID();
$user = wp_get_current_user();
$user_id = get_current_user_id();
$blog_id = get_current_blog_id();
$dd_status = get_post_meta($post_id, \'screening_status\', true);
$dd_analyst = get_post_meta($post_id, \'select_analyst\', true);
//Completed
if (\'Completed\' == $dd_status)
{
$args = array(
\'role\' => \'client\',
\'blog_id\' => $blog_id
);
$client_infos = get_users($args);
foreach($client_infos as $client_info)
{
$client_email = $client_info->user_email;
$to = $client_email;
$subject = \'Due diligence is Complete\';
$body = \'Lorem ipsum\';
wp_mail($to, $subject, $body);
}
}
}
add_filter(\'updated_postmeta\', \'email_notification_by_status\');
有人能告诉我我的代码出了什么问题吗?