26
August
There are several ways to get the user's name programmatically.
$uid = 1; // For example I have get detail of user ID 1 $account = \Drupal\user\Entity\User::load($uid); // pass your uid
Method 1
drupal_set_message($account->name->value);
Method 2
drupal_set_message($account->get("name")->value);
Method 3
drupal_set_message($account->getUsername());
Method 4
drupal_set_message($account->name->getValue()[0][value]);
© 2023.ZedAngle. All Rights Reserved.