feat: only approved comments to trigger notification (#485)

Avoid notifications for comments that are still waiting for moderation, and enable notifications only for approved comments.
pull/490/head
Shankang Ke 2022-03-27 00:11:58 +08:00 committed by GitHub
parent a321fcf96c
commit 30204e0394
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -83,7 +83,7 @@ function comment_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')) {
if (($parent_id != '') && ($spam_confirmed == '1')) {
$wp_email = kratos_option('m_username');
$to = trim(get_comment($parent_id)->comment_author_email);
$subject = __('[通知]您的留言有了新的回复', 'kratos');
@ -129,3 +129,4 @@ function comment_notify($comment_id)
}
}
add_action('comment_post', 'comment_notify');
add_action('comment_unapproved_to_approved', 'comment_notify');