You are here

function cleantalk_user_delete in Anti Spam by CleanTalk 7.2

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

Implements hook_user_delete().

File

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

Code

function cleantalk_user_delete($account) {
  $result = db_select('cleantalk_uids', 'c')
    ->fields('c', array(
    'ct_request_id',
    'ct_result_comment',
  ))
    ->condition('uid', $account->uid, '=')
    ->range(0, 1)
    ->execute();
  if ($result
    ->rowCount() > 0) {
    $ct_result = $result
      ->fetchObject();

    // If ct_result_comment is empty then user is approved by server.
    // But we delete it then user is not approved by admin.
    // We need to send negative feedback.
    _cleantalk_send_feedback($ct_result->ct_request_id, 0);
    db_delete('cleantalk_uids')
      ->condition('uid', $account->uid, '=')
      ->execute();
  }
}