You are here

function invite_process in Invite 6.2

Process a user that accepted an invitation.

Parameters

$invite: An invite object.

$account: The user object that accepted the invitation.

Return value

Array of target roles for the invited user.

1 call to invite_process()
invite_user in ./invite.module
Implementation of hook_user().

File

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

Code

function invite_process($invite, $account) {

  // Update the invitation record.
  db_query("UPDATE {invite} SET email = '%s', invitee = %d, joined = %d WHERE reg_code = '%s'", $account->mail, $account->uid, time(), $invite->reg_code);

  // Delete all invites to these e-mail addresses, except this one.
  db_query("DELETE FROM {invite} WHERE (email = '%s' OR email = '%s') AND reg_code <> '%s'", $invite->email, $account->mail, $invite->reg_code);

  // Add all users who invited this particular e-mail address to the
  // notification queue.
  db_query("INSERT INTO {invite_notifications} (uid, invitee) SELECT uid, %d from {invite} WHERE (email = '%s' OR email = '%s') AND canceled = 0", $account->uid, $invite->email, $account->mail);

  // Unblock the user account.
  db_query("UPDATE {users} SET status = 1 WHERE uid = %d", $account->uid);

  // Determine target roles for invited user.
  $roles = invite_target_roles($invite);

  // Allow other modules to act on the role escalation.
  $args = array(
    'invitee' => $account,
    'inviter' => $invite->inviter,
    'roles' => &$roles,
  );
  module_invoke_all('invite', 'escalate', $args);
  return $roles;
}