3C科技 娛樂遊戲 美食旅遊 時尚美妝 親子育兒 生活休閒 金融理財 健康運動 寰宇綜合

Zi 字媒體

2017-07-25T20:27:27+00:00
加入好友
Original Posts Send Comment Notification Email To Author In WordPress When a user left a comment on your site, and the comment get a new reply, this code will send a notification email to the author. Also, you can send a copy to yourself with Bcc to ensure this feature working fine. However, there is another issue. With default settings in WordPress, the email filed in comment form is not required. And that’s what we would customize in the next post. add_action( 'comment_post', 'send_comment_notification_mail', 10, 2 ); function send_comment_notification_mail( $comment_ID, $comment_approved ) { if( 1 === $comment_approved ){ $comment = get_comment( $comment_ID ); if($comment->comment_parent != 0){ $parent_id = $comment->comment_parent; $parent_comment = get_comment( $parent_id ); $author_mail = $parent_comment->comment_author_email; $post_link = get_permalink($parent_comment->comment_post_ID); $post_title = get_the_title($parent_comment->comment_post_ID); $comment_link = $post_link."#comment-".$parent_id; $comment_link = urldecode($comment_link); $to = $parent_comment->comment_author." "; $content = "Your comment in '".$post_title."' has a new reply。\n". $comment_link; $headers[] = 'From: ARON HACK '; // $headers[] = 'Cc: aronhack2018@gmail.com'; $headers[] = 'Bcc: aronhack2018@gmail.com'; wp_mail($to, "[AROH HACK] Comment Reply Notification", $content, $headers); } } } Hooks Used In This Tutorial get_commentswp_mail Related Posts The Complete WordPress Customization Tutorial – Just Copy And Paste And Work

本文由aronhackcom提供 原文連結

寫了 5860316篇文章,獲得 23313次喜歡
精彩推薦