You are here

function invite_find_invite in Invite 7.2

Finds the invitation to assign to the new account when the user is registering.

Parameters

$mail: The email address that is about to be registered.

Return value

An invite object.

2 calls to invite_find_invite()
invite_user_insert in ./invite.module
Implements hook_user_insert().
invite_user_presave in ./invite.module
Implements hook_user_presave().

File

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

Code

function invite_find_invite($mail) {
  $invite = invite_load_from_context();
  if (!$invite) {

    // Try to look up an invitation in case a user has been invited to join
    // the site, but did go straight to the site and signed up without
    // using the invite link.
    $code = db_query("SELECT reg_code FROM {invite} WHERE email = :mail", array(
      ':mail' => $mail,
    ))
      ->fetchField();
    if ($code) {
      $_SESSION[INVITE_SESSION] = $code;
      $invite = invite_load($code);
    }
  }
  return $invite;
}