drupal 8 load user from id code example
Example 1: drupal 8 get user
$current_user = \Drupal::currentUser();
$user = \Drupal\user\Entity\User::load($current_user->id());
// or just
$user = \Drupal\user\Entity\User::load(\Drupal::currentUser()->id());
Example 2: drupal 8 user_load
function user_load($uid, $reset = FALSE) {
if ($reset) {
\Drupal::entityManager()
->getStorage('user')
->resetCache(array(
$uid,
));
}
return User::load($uid);
}