diff --git a/alt_login.module b/alt_login.module index 035bc55102e90e6bb052b83b1a239532899a179b..a97d0012eb6dcf137ac8de3adceb133848aadd36 100644 --- a/alt_login.module +++ b/alt_login.module @@ -32,15 +32,16 @@ function alt_login_user_format_name_alter(&$name, $account) { if (!isset($names[$uid])) { // Anonymous users if (\Drupal::currentUser()->isAnonymous()) { + $anon = \Drupal::config('alt_login.settings')->get('display_anon'); $names[$uid] = \Drupal::token() - ->replace(\Drupal::config('alt_login.settings')->get('display_anon'), ['user' => $account]); + ->replace($anon, ['user' => $account], ['clear' => true]); } // Do the replacement if the module is configured. elseif ($template = \Drupal::config('alt_login.settings')->get('display')) { if (!$account instanceof UserInterface) { $account = User::load($account->id()); } - $names[$uid] = \Drupal::token()->replace($template, ['user' => $account]); + $names[$uid] = \Drupal::token()->replace($template, ['user' => $account], ['clear' => true]); } // If the above didn't produce a string or isn't configured, fall back to the username. if (empty($names[$uid])) {