function social_profile_social_user_name_display_suggestions in Open Social 8.9
Same name and namespace in other branches
- 8.5 modules/social_features/social_profile/social_profile.module \social_profile_social_user_name_display_suggestions()
- 8.6 modules/social_features/social_profile/social_profile.module \social_profile_social_user_name_display_suggestions()
- 8.7 modules/social_features/social_profile/social_profile.module \social_profile_social_user_name_display_suggestions()
- 8.8 modules/social_features/social_profile/social_profile.module \social_profile_social_user_name_display_suggestions()
- 10.3.x modules/social_features/social_profile/social_profile.module \social_profile_social_user_name_display_suggestions()
- 10.0.x modules/social_features/social_profile/social_profile.module \social_profile_social_user_name_display_suggestions()
- 10.1.x modules/social_features/social_profile/social_profile.module \social_profile_social_user_name_display_suggestions()
- 10.2.x modules/social_features/social_profile/social_profile.module \social_profile_social_user_name_display_suggestions()
Implements hook_social_user_name_display_suggestions().
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
File
- modules/
social_features/ social_profile/ social_profile.module, line 714 - The Social profile module.
Code
function social_profile_social_user_name_display_suggestions(AccountInterface $account) : array {
$suggestions = [];
/** @var \Drupal\profile\ProfileStorageInterface $storage */
$storage = \Drupal::entityTypeManager()
->getStorage('profile');
if ($user_profile = $storage
->loadByUser($account, 'profile', TRUE)) {
$accountname = trim($user_profile
->get('field_profile_first_name')->value . " " . $user_profile
->get('field_profile_last_name')->value);
if (strlen($accountname) > 0) {
// Add the full name with a default weight.
$suggestions['full_name'] = [
'name' => trim($accountname),
];
}
}
return $suggestions;
}