As the module work right now it does not fill out the name field in Discourse with anything but a split-up version of username.
To add full/real name I did the following:

1. add field to user, ie. Name (machine name field_name)
2. in /discourse_sso.module, add 'name' to payload, extract value of field with $account-function on line 39

Lines 50-56:

  $return_payload = base64_encode(http_build_query(array(
      'username' => $user->getAccountName(),
      'external_id' => $user->id(),
      // add this line below!
      'name' => $account->field_name->value,
      'email' => $user->getEmail(),
      'avatar_force_update' => true,
      'avatar_url' => $picture,

3. configure Discourse to lock local changes (Settings>Username>sso overrides name)

Comments

myram created an issue. See original summary.

myram’s picture

Issue summary: View changes

  • boromino committed 4b03e87 on 8.x-1.x
    Issue #2991684: Adding full name from Drupal to Discourse
    
boromino’s picture

Status: Active » Fixed
boromino’s picture

Select the user field to use in Drupal Discourse SSO settings.

Status: Fixed » Closed (fixed)

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