fix: 用户名不合规且未留邮箱时直接移入回收站
- 评论内容不合规:按原有设置处理(回收站/待审核/仅标记) - 用户名不合规且未留邮箱:直接移入回收站 - 用户名不合规但留了邮箱:修改用户名并发送通知邮件 - 记录详细的检测结果和处理原因
This commit is contained in:
@@ -7788,15 +7788,16 @@ function argon_async_spam_detection_handler($comment_id) {
|
||||
if ($result && isset($result['is_spam'])) {
|
||||
$content_spam = $result['is_spam'];
|
||||
$username_invalid = isset($result['username_invalid']) ? $result['username_invalid'] : false;
|
||||
$has_email = !empty($comment->comment_author_email);
|
||||
|
||||
// 更新用户统计
|
||||
argon_update_user_spam_stats($comment, $content_spam);
|
||||
|
||||
// 情况1:评论内容是垃圾评论
|
||||
if ($content_spam) {
|
||||
// 获取自动处理方式
|
||||
$auto_action = get_option('argon_comment_spam_detection_auto_action', 'trash');
|
||||
|
||||
// 情况1:评论内容不合规 - 直接按设置处理
|
||||
if ($content_spam) {
|
||||
if ($auto_action === 'trash') {
|
||||
// 移入回收站
|
||||
wp_trash_comment($comment_id);
|
||||
@@ -7820,12 +7821,30 @@ function argon_async_spam_detection_handler($comment_id) {
|
||||
]);
|
||||
|
||||
// 发送垃圾评论通知邮件给评论者
|
||||
if (!empty($comment->comment_author_email)) {
|
||||
if ($has_email) {
|
||||
argon_send_spam_notify_email($comment, $result, $detection_code);
|
||||
}
|
||||
}
|
||||
// 情况2:评论内容正常,但用户名不合规
|
||||
elseif ($username_invalid) {
|
||||
// 情况2.1:用户名不合规且没有留邮箱 - 直接移入回收站
|
||||
if (!$has_email) {
|
||||
wp_trash_comment($comment_id);
|
||||
update_comment_meta($comment_id, '_argon_spam_auto_trashed', true);
|
||||
update_comment_meta($comment_id, '_argon_username_invalid_no_email', true);
|
||||
|
||||
// 记录检测信息
|
||||
update_comment_meta($comment_id, '_argon_spam_detection_result', [
|
||||
'is_spam' => false,
|
||||
'reason' => $result['reason'],
|
||||
'username_invalid' => true,
|
||||
'username_reason' => $result['username_reason'],
|
||||
'action' => 'trash',
|
||||
'reason_detail' => '用户名不合规且未留邮箱'
|
||||
]);
|
||||
}
|
||||
// 情况2.2:用户名不合规但留了邮箱 - 修改用户名并发送通知
|
||||
else {
|
||||
$original_username = $comment->comment_author;
|
||||
|
||||
// 生成新用户名
|
||||
@@ -7858,8 +7877,7 @@ function argon_async_spam_detection_handler($comment_id) {
|
||||
'new_username' => $new_username
|
||||
]);
|
||||
|
||||
// 如果留了邮箱,发送用户名变更通知
|
||||
if (!empty($comment->comment_author_email)) {
|
||||
// 发送用户名变更通知
|
||||
argon_send_username_change_notify_email(
|
||||
$comment,
|
||||
$original_username,
|
||||
|
||||
Reference in New Issue
Block a user