You are here

function purge_users_worker in Auto Purge Users 7

Same name and namespace in other branches
  1. 7.2 purge_users.module \purge_users_worker()

Cron queue worker callback function.

Parameters

mixed $data: User account.

1 string reference to 'purge_users_worker'
purge_users_cron_queue_info in ./purge_users.module
Implements hook_cron_queue_info().

File

./purge_users.module, line 299
Purge users module file.

Code

function purge_users_worker($data) {
  $account = user_load($data);
  $method = variable_get('purge_user_cancel_method', 'user_cancel_reassign');

  // Modules use hook_user_delete() to respond to deletion.
  if ($method != 'user_cancel_delete') {

    // Allow modules to add further sets to this batch.
    module_invoke_all('user_cancel', array(), $account, $method);
  }

  // Log an entry to watchdog.
  watchdog('Purge users', 'User %user purged.', array(
    '%user' => $account->name,
  ), WATCHDOG_NOTICE);

  // Do heavy lifting here. Delete users and send an notification email.
  if (variable_get('purge_users_send_email_notification', '') == 1) {
    purge_users_send_notification($account);
  }

  // Perform user deletion operation.
  user_delete($account->uid);
}