You are here

function name_user_format_name_alter_preload in Name Field 8

Internal helper function to load the user account if required.

Recursion check in place after RealName module issue queue suggested that there were issues with token based recursion on load.

1 call to name_user_format_name_alter_preload()
name_user_format_name_alter in ./name.module
Implements hook_user_format_name_alter().

File

./name.module, line 140
Defines an API for displaying and inputing names.

Code

function name_user_format_name_alter_preload($account) {
  static $in_preload = FALSE;
  if (!$in_preload && !isset($account->realname)) {
    $field_name = Drupal::config('name.settings')
      ->get('user_preferred');
    if ($field_name && FieldConfig::loadByName('user', 'user', $field_name)) {
      $in_preload = TRUE;
      $account = User::load($account
        ->id());
      $in_preload = FALSE;
    }
  }
}