You are here

function user_email_verification_delete_account in User email verification 7

Queue worker callback for running a single task. Delete user account when e-mail address has not been verified after extended verification period has passed.

Parameters

$uid: User ID to be deleted

1 string reference to 'user_email_verification_delete_account'
user_email_verification_cron_queue_info in ./user_email_verification.module
Implements hook_cron_queue_info().

File

./user_email_verification.module, line 118
This module allows you to have e-mail verification and in meanwhile allowing the users to type their own passwords. If they do not verify their accounts in a certain time interval the user will be blocked.

Code

function user_email_verification_delete_account($uid) {

  // Load the account before canceling it
  $account = user_load($uid);
  if ($account) {
    if (module_exists('rules')) {

      // Invoke rules event
      rules_invoke_event('user_email_verification_account_deleted', $account);
    }

    // Notify account about cancellation
    $op = 'status_canceled';
    _user_mail_notify($op, $account);

    // Get the cancel method
    $user_cancel_method = variable_get('user_cancel_method');
    user_cancel(array(), $uid, $user_cancel_method);

    // user_cancel() initiates a batch process. Run it manually.
    $batch =& batch_get();
    $batch['progressive'] = FALSE;
    batch_process();
    watchdog('user', 'User with uid %uid has been deleted due to e-mail address not being verified within extended verification period.', array(
      '%uid' => $uid,
    ));
  }
  else {
    watchdog('user', 'User with uid %uid could not be deleted because the uid does not exist anymore.', array(
      '%uid' => $uid,
    ));
  }
}