drupal 8 get user uid code example
Example: 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());
$current_user = \Drupal::currentUser();
$user = \Drupal\user\Entity\User::load($current_user->id());
// or just
$user = \Drupal\user\Entity\User::load(\Drupal::currentUser()->id());