You are here

function invite_delete in Invite 7.2

Same name and namespace in other branches
  1. 5.2 invite.module \invite_delete()
  2. 5 invite.module \invite_delete()
  3. 6.2 invite.module \invite_delete()
  4. 7.4 invite.module \invite_delete()

Delete an invite from the database.

Parameters

$conditions: An array of conditions.

2 calls to invite_delete()
example_delete_invite in ./invite.api.php
Delete an invite.
invite_user_delete in ./invite.module
Implements hook_user_delete().

File

./invite.module, line 790
Allows your users to send and track invitations to join your site.

Code

function invite_delete($conditions) {
  if (empty($conditions) || !is_array($conditions)) {
    return;
  }
  $select_query = db_select('invite', 'i')
    ->fields('i', array(
    'invitee',
  ));
  $delete_query = db_delete('invite');
  foreach ($conditions as $key => $value) {
    $select_query = $select_query
      ->condition($key, $value);
    $delete_query = $delete_query
      ->condition($key, $value);
  }
  $invitees = $select_query
    ->execute()
    ->fetchCol();
  $invitees = array_filter($invitees);
  $delete_query
    ->execute();

  // Clean up the notification queue.
  foreach ($invitees as $invitee) {
    db_delete('invite_notifications')
      ->condition('invitee', $invitee)
      ->execute();
  }
}