- Issue created by @bluegeek9
Users mapped to a contact can use the contact's full name as their Display Name. User will want to control how thier name is formatted.
Add a form element to the user's edit page to select a name format.
The value will be stored in user_data
If no format is select we can either:
have a setting in crm.user.settings for the default format
,or
User the contact's label
This is the existing code.
/**
* Implements hook_user_format_name_alter().
*/
function crm_user_format_name_alter(&$name, AccountInterface $account) {
$override = \Drupal::config('crm.crm_user.settings')->get('display_name');
if (!$override) {
return;
}
$crm_users = \Drupal::entityTypeManager()
->getStorage('crm_user')
->loadByProperties(['user' => $account->id()]);
if ($crm_users != NULL) {
$crm_user = reset($crm_users);
$name = $crm_user->getContact()?->label();
}
}
Active
1.0
Code