Drupal

The website encountered an unexpected error. Please try again later
| 6 min read
"The website encountered an unexpected error. Please try again later." this is the most common error encountered by a Drupal developer. Usually, errors are logged by Drupal and the logs can be accessed from Admin->Reports->Recent log messages. But when you get "The website encountered an unexpected error. Please try again later." you cannot even access the reports dashboard.
Zyxware default image3
| 2 min read
In pre Drupal 8 era, the global variable $user was available every where, from you can easily get the current logged in user id. For all new version of Drupal, you should use \Drupal::currentUser()->id() Once you have the user id, you can use the User::load to get the user object.