You are here

function invite_token_data in Invite 7.2

Provide token data for use in invite message replacements.

Parameters

$args: Associative array of additional arguments to merge in the invite object, or a complete invite object.

Return value

Array of tokens suitable as input for token_replace().

3 calls to invite_token_data()
invite_form_submit in ./invite.module
Forms API callback; process submitted form data.
invite_get_subject in ./invite.module
Return the invite e-mail subject.
invite_page_form in ./invite.module
Generate the invite page form.

File

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

Code

function invite_token_data($args = array()) {
  global $user;
  if (is_object($args)) {

    // $args is an invite object.
    $invite = $args;
  }
  else {

    // Create an empty invite for token replacement.
    $invite = invite_create();

    // If no specific invite is provided for replacement, the newly generated reg_code is irrelevant here.
    unset($invite->reg_code);
  }
  if (is_array($args)) {
    foreach ($args as $key => $value) {
      $invite->{$key} = $value;
    }
  }
  if (empty($invite->inviter) && !empty($invite->uid)) {
    $invite->inviter = user_load($invite->uid);
  }
  return array(
    'user' => empty($invite->inviter) ? $user : $invite->inviter,
    'profile' => empty($invite->inviter) ? $user : $invite->inviter,
    'invite' => $invite,
  );
}