你的问题是有条件的,而不是用过的动作(我想)。
该行可能在任何情况下都不会验证:
if( ( $_POST[\'post_status\'] == \'publish\' ) && ( $goalsupport === $totalsupport ) ) {
我现在不知道$goalsupport和$goalsupport是什么,这两个变量在您的代码中都没有定义,所以我将删除它们。用这一行更改该行:
if( get_post_status( $post_id ) == \'publish\' ) {
因此,代码应为:
function emailNotificationSuccess($post_id) {
if( get_post_status( $post_id ) == \'publish\' ) {
$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\');