WordPress 댓글 회신 이메일을 보내지 않습니까?메시지 댓글 이메일 알림 무료 플러그인 코드

워드프레스(WordPress)댓글 답글이 이메일을 보내지 않으면 어떻게 해야 하나요?

메시지 댓글 이메일 알림 무료 플러그인 코드

일반 대외 무역전자 상거래실무자, 모든 사용워드프레스 웹사이트하다웹 프로모션, 댓글 메시지에 답장을 보낼 수 없는 경우가 있습니다.

그렇다면 플러그인이 없는 코드를 사용하여 WordPress 메시지 댓글 회신 이메일 알림 문제를 해결할 수 있습니다.

WP 테마의 functions.php 파일에 다음 코드를 추가하세요.

/**
* 评论回复邮件通知 By 陈沩亮
* 文章地址:https://www.chenweiliang.com/cwl-636.html
**/
 function cwl_comment_mail_notify($comment_id) {
     $comment = get_comment($comment_id);//根据id获取这条评论相关数据
     $content=$comment->comment_content;
     //对评论内容进行匹配
     $match_count=preg_match_all('/<a href="#comment-([0-9]+)?" rel="nofollow">/si',$content,$matchs);
     if($match_count>0){//如果匹配到了
         foreach($matchs[1] as $parent_id){//对每个子匹配都进行邮件发送操作
             SimPaled_send_email($parent_id,$comment);
         }
     }elseif($comment->comment_parent!='0'){//以防万一,有人故意删了@回复,还可以通过查找父级评论id来确定邮件发送对象
         $parent_id=$comment->comment_parent;
         SimPaled_send_email($parent_id,$comment);
     }else return;
 }
 add_action('comment_post', 'cwl_comment_mail_notify');
 function SimPaled_send_email($parent_id,$comment){//发送邮件的函数 by www.chenweliang.com
     $admin_email = get_bloginfo ('admin_email');//管理员邮箱
     $parent_comment=get_comment($parent_id);//获取被回复人(或叫父级评论)相关信息
     $author_email=$comment->comment_author_email;//评论人邮箱
     $to = trim($parent_comment->comment_author_email);//被回复人邮箱
     $spam_confirmed = $comment->comment_approved;
     if ($spam_confirmed != 'spam' && $to != $admin_email && $to != $author_email) {
         $wp_email = 'no-reply@' . preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME'])); // e-mail 发出点, no-reply 可改为可用的 e-mail.
         $subject = '你在 [' . get_option("blogname") . '] 的留言有了回应';
         $message = '<div style="background-color:#eef2fa;border:1px solid #d8e3e8;color:#111;padding:0 15px;-moz-border-radius:5px;-webkit-border-radius:5px;-khtml-border-radius:5px;">
             <p>' . trim(get_comment($parent_id)->comment_author) . ', 你好!</p>
             <p>你曾在《' . get_the_title($comment->comment_post_ID) . '》的留言:<br />'
             . trim(get_comment($parent_id)->comment_content) . '</p>
             <p>' . trim($comment->comment_author) . ' 给你的回复:<br />'
             . trim($comment->comment_content) . '<br /></p>
             <p>你可以点击 <a href="' . htmlspecialchars(get_comment_link($parent_id,array("type" => "all"))) . '">查看回复的完整內容</a></p>
             <p>欢迎再度光临 <a href="' . get_option('home') . '">' . get_option('blogname') . '</a></p>
             <p>(此邮件由系统自动发出, 请勿回复)</p></div>';
         $from = "From: \"" . get_option('blogname') . "\" <$wp_email>";
         $headers = "$from\nContent-Type: text/html; charset=" . get_option('blog_charset') . "\n";
         wp_mail( $to, $subject, $message, $headers );
     }
 }

희망 첸 웨이량 블로그( https://www.chenweiliang.com/ ) 공유 "워드프레스 댓글 답글이 이메일을 보내지 않으면 어떻게 해야 하나요?플러그인 코드 없이 메시지, 댓글, 이메일 알림을 남겨주세요"라는 메시지가 도움이 됩니다.

이 기사의 링크를 공유하는 것을 환영합니다:https://www.chenweiliang.com/cwl-636.html

최신 업데이트를 받으려면 Chen Weiliang 블로그의 Telegram 채널에 오신 것을 환영합니다!

🔔 채널 상위 디렉토리에서 귀중한 "ChatGPT 콘텐츠 마케팅 AI 도구 사용 가이드"를 가장 먼저 받아보세요! 🌟
📚 이 가이드에는 엄청난 가치가 담겨 있습니다. 🌟이것은 흔치 않은 기회입니다. 놓치지 마세요! ⏰⌛💨
당신이 원한다면 공유하고 좋아하십시오!
당신의 공유와 좋아요는 우리의 지속적인 동기 부여입니다!

 

发表 评论

귀하의 이메일 주소는 공개되지 않습니다. 必填 项 已 用 * 标注

맨위로 스크롤