You are here

function social_user_export_last_name in Open Social 8.2

Returns last name of user.

Parameters

\Drupal\user\UserInterface $account: The account to get the data for.

Return value

string Returns last name of the user.

1 call to social_user_export_last_name()
ExportUser::exportUserOperation in modules/social_features/social_user_export/src/ExportUser.php
Callback of one operation.

File

modules/social_features/social_user_export/social_user_export.module, line 125
The Social User Export module.

Code

function social_user_export_last_name(UserInterface $account) {
  $last_name = '';

  /** @var \Drupal\profile\ProfileStorageInterface $storage */

  // Check if entity type 'profile' exists.
  try {
    $storage = \Drupal::entityTypeManager()
      ->getStorage('profile');
    if (!empty($storage)) {
      if ($user_profile = $storage
        ->loadByUser($account, 'profile', TRUE)) {
        $last_name = $user_profile
          ->get('field_profile_last_name')->value;
      }
    }
  } catch (InvalidPluginDefinitionException $e) {
    $last_name = '';
  }
  return $last_name;
}