为了改善留言者和作者之间的沟通,我正在修改一个脚本,当收到回复时,它会向留言者发送电子邮件。
以下是迄今为止代码的外观:
<?php
/*
Plugin Name: Comment Reply Notifier
Plugin URI: http://wordpress.stackexchange.com/users/24875/christine-cooper
Version: 0.1
Author: Christine Cooper
Description: When someone replies to a comment, an email is sent to the writer of the replied comment.
Author URI: http://wordpress.stackexchange.com/users/24875/christine-cooper
*/
add_action(\'comment_post\', \'comment\');
function comment($comment_reply_id)
{
$comment = get_comment($comment_reply_id);
if($comment->comment_parent != 0)
{
$old_comment = get_comment($comment->comment_parent);
if($old_comment->user_id == 0)
{
$email = $old_comment->comment_author_email;
$name = $comment->comment_author;
$content = $comment->comment_content;
$post = get_post($comment->comment_post_ID);
$title = $post->post_title;
$link = get_permalink($comment->comment_post_ID);
$blogname = wp_specialchars_decode(get_option(\'blogname\'), ENT_QUOTES);
$subject = sprintf(\'Comment reply: "%2$s" at %1$s\', $blogname, $title );
$notify_message = sprintf(\'Someone replied to a comment you left on: %s\', $title ) . "\\r\\n";
$notify_message .= sprintf( \'Reply by: %1$s \', $name ) . "\\r\\n";
$notify_message .= \'Comment: \' . "\\r\\n" . $content . "\\r\\n\\r\\n";
$notify_message .= \'You can reply to the comment here: \' . "\\r\\n";
$notify_message .= $link . "#comments\\r\\n\\r\\n";
$message_headers = "Content-Type: text/plain; charset=\\"" . get_option(\'blog_charset\') . "\\"\\n";
wp_mail( $email, $subject, $notify_message, $message_headers );
}
}
}
?>
它很好用,可以随意试用。我想补充两件事。我想调整邮件的名称和电子邮件。因此,我想将Blog名称设置为发件人的名称,并将自定义电子邮件设置为发件人的邮件(例如
[email protected]).我该怎么做?