You are here

function cleantalk_user_presave in Anti Spam by CleanTalk 8

Same name and namespace in other branches
  1. 7 cleantalk.module \cleantalk_user_presave()
  2. 7.2 cleantalk.module \cleantalk_user_presave()

Implements hook_user_presave().

@FIXME The $edit and $category parameters are gone in Drupal 8. They have been left here in order to prevent 'undefined variable' errors, but they will never actually be passed to this hook. You'll need to modify this function and remove every reference to them.

File

./cleantalk.module, line 302
Main CleanTalk integration module functions.

Code

function cleantalk_user_presave(\Drupal\user\UserInterface $account) {
  $ct_result = _cleantalk_ct_result();
  if ($account
    ->isNew() && @empty($ct_result['ct_request_id'])) {
    $spam_check = array();
    $spam_check['type'] = 'register';
    $spam_check['sender_email'] = !empty($_POST['mail']) ? $_POST['mail'] : '';
    $spam_check['sender_nickname'] = !empty($_POST['name']) ? $_POST['name'] : '';
    $spam_result = _cleantalk_check_spam($spam_check);
    if (isset($spam_result) && is_array($spam_result) && $spam_result['errno'] == 0 && $spam_result['allow'] != 1) {
      _cleantalk_die($spam_result['ct_result_comment']);
    }
  }
}