function cleantalk_comment_presave in Anti Spam by CleanTalk 9.1.x
Same name and namespace in other branches
- 8.4 cleantalk.module \cleantalk_comment_presave()
- 8 cleantalk.module \cleantalk_comment_presave()
- 8.3 cleantalk.module \cleantalk_comment_presave()
- 7.5 cleantalk.module \cleantalk_comment_presave()
- 7 cleantalk.module \cleantalk_comment_presave()
- 7.2 cleantalk.module \cleantalk_comment_presave()
- 7.4 cleantalk.module \cleantalk_comment_presave()
Implements hook_comment_presave().
File
- ./
cleantalk.module, line 316
Code
function cleantalk_comment_presave(\Drupal\comment\CommentInterface $comment) {
$ct_result = CleantalkFuncs::_cleantalk_ct_result();
if (!empty($ct_result['ct_request_id'])) {
if ($ct_result['ct_result_allow'] === 0 && \Drupal::config('cleantalk.settings')
->get('cleantalk_check_comments_automod')) {
if (version_compare(\Drupal::VERSION, '8.3.0') >= 0) {
$comment
->setUnpublished();
}
else {
$comment
->setPublished(false);
}
}
}
}