/* comment_mail_notify v1.0 by willin kan. (無勾選欄) */
function comment_mail_notify($comment_id) {
$admin_email = get_bloginfo ('admin_email'); // $admin_email 可改為你指定的 e-mail.
$comment = get_comment($comment_id);
$comment_author_email = trim($comment->comment_author_email);
$parent_id = $comment->comment_parent ? $comment->comment_parent : '';
$to = $parent_id ? trim(get_comment($parent_id)->comment_author_email) : '';
$spam_confirmed = $comment->comment_approved;
if (($parent_id != '') && ($spam_confirmed != 'spam') && ($to != $admin_email) && ($comment_author_email == $admin_email)) {
/* 下面的判斷式,決定發出郵件的必要條件:
($parent_id != '') && ($spam_confirmed != 'spam'): 回覆的, 而且不是 spam 才可發, 必须!!
($to != $admin_email) : 不發給 admin.
($comment_author_email == $admin_email) : 只有 admin 的回覆才可發.
可視個人需要修正以上條件.
*/
$wp_email = '[email protected]' . preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME'])); // e-mail 發出點, no-reply 可改為可用的 e-mail.
$subject = '您在【' . get_option("blogname") . '】的留言有回复了!去看看吧 ^_^';
$message = '
<p style="margin: 1em 40px 1em 40px;background-color:#eef2fa;border:1px solid #d8e3e8;color:#111;padding: 0 15px;-moz-border-radius:5px;-webkit-border-radius:5px;-khtml-border-radius:5px;border-radius:5px;">
<p>Hi !<strong>' . trim(get_comment($parent_id)->comment_author) . '</strong>,您好!
您曾在<strong>《' . get_the_title($comment->comment_post_ID) . '》</strong>的留言有了新回复。</p></p>
<p style="margin: 1em 40px 1em 40px;background-color:#eef2fa;border:1px solid #d8e3e8;color:#111;padding: 0 15px;-moz-border-radius:5px;-webkit-border-radius:5px;-khtml-border-radius:5px;border-radius:5px;"><p><strong>
您</strong>说:' . trim(get_comment($parent_id)->comment_content) . '</p>
<p><strong>' . trim($comment->comment_author) . '</strong>说:
' . trim($comment->comment_content) . '</p>
<p>您能够点击<a href="' . htmlspecialchars(get_comment_link($parent_id)) . '">查看完好的回复內容。</a></p>
<p>欢送再度莅临 <a href="' . get_option('home') . '">' . get_option('blogname') . '</a></p>
<p>(此邮件由零碎主动发送,请勿回复。)</p></p>
';
$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 );
echo 'mail to ', $to, '
' , $subject, $message; // for testing
}
}
add_action('comment_post', 'comment_mail_notify');
// -- END ----------------------------------------
以上就是安达网络工作室关于《WordPress评论邮件通知无插件实现思路及代码》的一些看法。更多内容请查看本栏目更多内容!
本文实例讲述了WordPress获取文章内容摘要的办法。分享给大家供大家参考。详细如下: 第一个函数是讲述了能...
get_template_part() 用来援用模板文件,相似于 get_header()、get_sidebar() 和 get_footer(),只不过这个...
wordpress操作数据库用一个全局变量$wpdb来进行各种操作,应用的时分先在函数申明global $wpdb,而后调用它...
要害字形容:工作 预备 装置   数据库 用户 创立 权限 应用 软件 解说 WordPress 的装置前的一些预备工...
此时假如上传一个不在预约义的平安扩大名列表,如.lrc,会报错: File type does not meet security guidel...
本文实例讲述了wordpress完成读者墙的办法。分享给大家供大家参考。详细完成办法如下: 1.复制PAGE.php页面...