Get the current user in drupal 8 By editor, 2 December, 2015 Question How to get the current user, user ID, user data on drupal 8 ? How To check if the current page is the homepage of Drupal 8 ? Example: //use Drupal\user\Entity\User; $userCurrent = \Drupal::currentUser(); $user = \Drupal\user\Entity\User::load($userCurrent->id()); $name = $user->getUsername(); How To check if the current page is the homepage in Drupal 8 As drupal_is_front_page() on drupal 7, you can use path.matcher service of drupal 8. Example: $is_front_page = \Drupal::service('path.matcher')->isFrontPage(); Tags Drupal 8 User Code Add new comment