You are here

function user_email_verification_tokens in User email verification 7

Same name and namespace in other branches
  1. 8 user_email_verification.tokens.inc \user_email_verification_tokens()

Implements hook_tokens().

File

./user_email_verification.tokens.inc, line 30
Builds placeholder replacement tokens for user-related data.

Code

function user_email_verification_tokens($type, $tokens, array $data = array(), array $options = array()) {
  $sanitize = !empty($options['sanitize']);
  $replacements = array();
  if ($type == 'user' && !empty($data['user'])) {
    $account = $data['user'];
    foreach ($tokens as $name => $original) {
      switch ($name) {

        // Basic user account information.
        case 'verify-email':

          // Let's generate the verify link for this account
          $replacements[$original] = user_email_verification_url($account);
          break;
        case 'verify-email-extended':

          // Let's generate the extended verify link for this account
          $replacements[$original] = user_email_verification_extended_url($account);
          break;
      }
    }
  }
  return $replacements;
}