Problem/Motivation

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.

Steps to reproduce

Proposed resolution

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

Remaining tasks

User interface changes

API changes

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();
  }

}

Data model changes

Issue fork crm-3528965

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

bluegeek9 created an issue. See original summary.

bluegeek9’s picture

Assigned: Unassigned » bluegeek9

bluegeek9’s picture

Assigned: bluegeek9 » Unassigned
Status: Active » Needs review

bluegeek9 changed the visibility of the branch 1.0.x to hidden.

  • bluegeek9 committed 014414be on 1.0.x
    Issue #3528965 by bluegeek9: User Display Name preference
    
bluegeek9’s picture

Status: Needs review » Fixed
//www.flaticon.com/free-icons/thank-you Thank you for your contribution! Your continued support makes this project sustainable.
There are multiple ways to show appreciation for the work contributed to this project including:
  • Triage issues and adding more context to existing issues.
  • Flagging CRM as a favorite on the project page to help others discover it and show your support.
  • Review the Developer Docs for accuracy and clarity.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.