You are here

function signup_user_cancel in Signup 7

Implements hook_user_cancel().

When a user is deleted, cancel all of that user's signups to remove all instances of that user from the {signup_log} table, free up space in nodes with signup limits, etc.

Related topics

File

./signup.module, line 658
The Signup module (http://drupal.org/project/signup) manages replies to nodes. In particular, it's good for event management. Signup supports sending reminder emails and automatically closing signups for nodes with a start time, via the Event…

Code

function signup_user_cancel($edit, $account, $method) {
  $uids = array();
  if (is_array($edit['accounts'])) {

    // A multi-user delete from Admin > User management > Users.
    $uids = $edit['accounts'];
  }
  else {

    // A single-user delete from the edit tab on the user's profile.
    if (!empty($account->uid)) {
      $uids[] = $account->uid;
    }
  }
  if (!empty($uids) && is_array($uids)) {
    foreach ($uids as $uid) {
      $signups = db_query("SELECT * FROM {signup_log} WHERE uid = :uid", array(
        ':uid' => $uid,
      ));

      // TODO: Test
      foreach ($signups as $signup) {
        signup_cancel_signup($signup);
      }
    }
  }
}