You are here

function _auto_username_patternprocessor in Automatic User Names 5

Same name and namespace in other branches
  1. 6 auto_username.module \_auto_username_patternprocessor()
  2. 7 auto_username.module \_auto_username_patternprocessor()

Process an account and return its new username according to the current pattern.

Parameters

$account: The user object to process.

Return value

The new name for the user object.

1 call to _auto_username_patternprocessor()
auto_username_user in ./auto_username.module
Implementation of hook_user().

File

./auto_username.module, line 170

Code

function _auto_username_patternprocessor($account) {
  $output = '';

  // Because token.module doesn't let us escape individual tokens, we have to
  // bypass its normal processing routine.  This pattern is borrowed almost
  // entirely from pathauto.
  $placeholders = auto_username_get_placeholders('user', $account);
  $pattern = variable_get('aun_pattern', '');
  if (trim($pattern)) {
    $output = str_replace($placeholders['tokens'], $placeholders['values'], $pattern);

    //$output = token_replace($pattern, 'user', $account);
    if (variable_get('aun_php', 0)) {
      $output = drupal_eval($output);
    }
  }
  return trim($output);
}