标签

Honeymoon - Thomas Ng

归档

近期文章

Our Visitor

008080
用户今天 : 15
合计查看 : 15789
谁是在线的 : 0
你的IP地址 : 74.7.241.12

wordpress实现文章评论回复后邮件通知

本文章实现 wordpress实现文章评论回复后邮件通知

不懂的可以评论或联系我邮箱:owen@owenzhang.com

著作权归OwenZhang所有。商业转载请联系OwenZhang获得授权,非商业转载请注明出处。

安装邮件插件

插件名称:WP Mail SMTP by WPForms – The Most Popular SMTP and 电邮日志 Plugin

WP Mail SMTP

配置邮件插件

pz1

pz2

pz3

测试插件发送邮件

cs1

主题functions.php添加通知代码

文件位置:

/www/wwwroot/owenblog-wordpress/wp-content/themes/personal-cv-resume/functions.php

文件最后添加,如果有存在,就忽略此步骤

if ( ! function_exists( 'comment_mail_notify' ) ) :

function comment_mail_notify($comment_id)
{
    $comment        = get_comment($comment_id);
    $parent_id      = $comment->comment_parent ? $comment->comment_parent : '';
    $spam_confirmed = $comment->comment_approved;
    if (($parent_id != '') && ($spam_confirmed != 'spam')) {
        $to       = trim(get_comment($parent_id)->comment_author_email);
        $subject  = '[OwenBlog]您的留言有了新的回复';
        $message  = 'Hi ' . trim(get_comment($parent_id)->comment_author) . ':

您有一条留言有了新的回复。

原文:' . mb_substr(trim(get_comment($parent_id)->comment_content), 0, 20, 'utf-8') . '......

回复:' . mb_substr(trim($comment->comment_content), 0, 10, 'utf-8') . '......

作者:' . trim($comment->comment_author) . '

详细查看:' . get_comment_link($comment->comment_ID) . '

发件人:' . htmlspecialchars_decode(get_option('blogname'), ENT_QUOTES) . '

时间:' . date("Y-m-d H:i:s", time()) . '

该邮件由系统自动发出,如果不是您本人操作,请忽略此邮件。';

        wp_mail($to, $subject, $message);
    }
}

endif;
add_action( 'comment_post', 'comment_mail_notify' );

回复评论后自动发送邮件

pl0

pl1

pl2

pl3

Buy me a cup of coffee :)

觉得对你有帮助,就给我打赏吧,谢谢!

微信赞赏码链接,点击跳转:

wordpress实现文章评论回复后邮件通知插图9

Tags:

2 thoughts on “wordpress实现文章评论回复后邮件通知

发表回复

Your email address will not be published. Required fields are marked *.

*
*