Getting current user ID in a custom block [closed]
Question
I have a custom block where I need to use [current-user:uid]
in just one text. In Drupal 7, I would have used PHP input filter
. How can I do this in Drupal 8?
La solution
You may use twig bamboo or a preprocess function where you load the current user.
function hook_preprocess_HOOK(&$variables) {
$vars['user'] = \Drupal\user\Entity\User::load(\Drupal::currentUser()->id());}
Licencié sous: CC-BY-SA avec attribution
Non affilié à drupal.stackexchange