You are here

function openid_connect_user_format_name_alter in OpenID Connect / OAuth client 8

Same name and namespace in other branches
  1. 2.x openid_connect.module \openid_connect_user_format_name_alter()

Implements hook_user_format_name_alter().

File

./openid_connect.module, line 93
Hook implementations of the OpenID Connect module.

Code

function openid_connect_user_format_name_alter(&$name, $account) {

  // Ensure that usernames are not displayed if they are email addresses, or if
  // they are generated names starting with 'oidc_'.
  $oidc_name = \Drupal::service('user.data')
    ->get('openid_connect', $account
    ->id(), 'oidc_name');
  if (!empty($oidc_name) && strpos($name, 'oidc_') !== 0 && strpos($name, '@') !== FALSE) {
    $name = $oidc_name;
  }
}