我正在处理一些自动电子邮件。我对add\\u action和do\\u action相当陌生。我很难理解它。该网站设定了许多目标,人们可以随着时间的推移达到这些目标。我想在他们进球时给他们发一封电子邮件。下面的代码将在帖子更新时发送该电子邮件,但这不起作用。我把它放在那里只是为了确保邮件发出。我不知道应该使用什么add\\u操作。要做到这一点,我应该寻找什么样的参考资料?
function emailNotificationSuccess($post_id) {
if( ( $_POST[\'post_status\'] == \'publish\' ) && ( $goalsupport === $totalsupport ) ) {
$post = get_post($post_id);
$author = get_userdata($post->post_author);
$totalsupport = countSupportForAll($post->ID);
$goalsupport = get_post_meta( $post->ID, \'sj_campaign_goal\', true );
$supporter_email = get_post_meta( $post_id, \'sj_campaign_email\', true );
$message = "Hi ".$author->display_name.",
Congrats! You have reached your goal!
Your , ".$post->post_title." is a success!
".get_permalink( $post_id )."
";
wp_mail($supporter_email, "You just reached your goal!", $message);
}
}
add_action(\'post_updated\', \'emailNotificationSuccess\');