In drupal 8 you can get current logged in users info by using currentUser() method.
$currentAccount = \Drupal::currentUser();
$currentAccount->id(); /To get User ID
$currentAccount->getUsername();//To get User Name
- Add new comment
- 6775 views