我需要发送一个访问者的通知,该访问者的评论已经发布
我创建此函数就是为了:
/*************************************************
** COMMENT APPROVED HOOK
*************************************************/
add_action(\'transition_comment_status\', \'siteit_comment_approved\', 10, 3);
function siteit_comment_approved($new_status, $old_status, $comment) {
if($old_status != $new_status) {
if($new_status == \'approved\') {
if(is_email($comment->comment_author_email)) {
$data[\'pid\'] = $comment->comment_post_ID;
$data[\'ptitle\'] = get_the_title( $data[\'pid\'] );
$data[\'plink\'] = get_permalink( $data[\'pid\'] );
$data[\'name\'] = $comment->comment_author;
$data[\'email\'] = $comment->comment_author_email;
$data[\'date\'] = $comment->comment_date;
$subject = of_get_option(THEME_PREF.\'ntf_cmnt_approved_esubject\');
$message = of_get_option(THEME_PREF.\'ntf_cmnt_approved_ebody\');
if( $subject && $message ) {
$subject = str_replace(\'[author_name]\', $data[\'name\'], $subject);
$subject = str_replace(\'[post_title]\', $data[\'ptitle\'], $subject);
$message = str_replace(\'[author_name]\', $data[\'name\'], $message);
$message = str_replace(\'[author_email]\', $data[\'email\'], $message);
$message = str_replace(\'[comment_date]\', $data[\'date\'], $message);
$message = str_replace(\'[post_title]\', $data[\'ptitle\'], $message);
$message = str_replace(\'[post_link]\', $data[\'plink\'], $message);
$headers[] = \'Content-Type: text/html; charset=UTF-8\';
$headers[] = \'From: \'.of_get_option(THEME_PREF.\'define_sitename_meta\').\' <\'.of_get_option(THEME_PREF.\'define_admin_email\').\'>\';
$mailResponse = wp_mail( $data[\'email\'], $subject, $message, $headers );
// if( is_user_logged_in() ) {
// echo \'<pre style="z-index: 999; position: relative;">Mail DATA:\'."<br>";
// print_r($data);
// echo \'</pre>\'."<br>";
// echo \'<pre style="z-index: 999; position: relative;">subject:\'."<br>";
// print_r($subject);
// echo \'</pre>\'."<br>";
// echo \'<pre style="z-index: 999; position: relative;">message:\'."<br>";
// print_r($message);
// echo \'</pre>\'."<br>";
// echo \'<pre style="z-index: 999; position: relative;">message:\'."<br>";
// print_r($headers);
// echo \'</pre>\'."<br>";
// echo \'<pre style="z-index: 999; position: relative;">MailResponse:\'."<br>";
// print_r($mailResponse);
// echo \'</pre>\'."<br>";
// }
}
}
}
}
}
在代码下面,我添加了一些打印以检查数据是否正确
所有
print_r
\'s返回正确的数据。“只是”
$mailResponse
“
不返回任何内容。
有什么想法吗?