diff --git a/alt_login.module b/alt_login.module index 32b1c86a03f1688287171197f020409b3fda6b97..ceaca7c87e366edaad379c38974fa4d607b3af4f 100644 --- a/alt_login.module +++ b/alt_login.module @@ -26,7 +26,7 @@ function alt_login_help($route_name, $route_match) { * @note there's no easy way to dedupe accounts' display names. */ function alt_login_user_format_name_alter(&$name, AccountInterface $account) { - if ($account->isAnonymous()) { + if ($account->isAnonymous()) { // includes accounts tha // This will be the configured 'anonymous' value return; } @@ -34,14 +34,14 @@ function alt_login_user_format_name_alter(&$name, AccountInterface $account) { $uid = $account->id(); if (!isset($names[$uid])) { // Anonymous users - if (\Drupal::currentUser()->isAnonymous()) { + if (\Drupal::currentUser()->isAnonymous() and !$account->isNew()) { $anon = \Drupal::config('alt_login.settings')->get('display_anon'); $names[$uid] = \Drupal::token() ->replace($anon, ['user' => $account], ['clear' => true]); } // Do the replacement if the module is configured. elseif ($template = \Drupal::config('alt_login.settings')->get('display')) { - $user = User::load($uid); + $user = $account instanceOf UserInterface ? $account : User::load($uid); $names[$uid] = \Drupal::token()->replace( $template, ['user' => $user], @@ -79,6 +79,7 @@ function alt_login_form_alter(&$form, $form_state, $form_id) { $user = $form_state->getFormObject()->getEntity(); $aliases = alt_login_get_aliases($user); $namefield = &$form['account']['name']; + dump($aliases); if (empty($aliases['username'])) { if ($user->isNew()) { $namefield['#access'] = FALSE;