Print custom user fields in Drupal 8

Public

Get raw version
php
  1. function theme_preprocess_node(&$variables){
  2. $node = $variables['node'];
  3. $variables['firstname'] = $node->getOwner()->field_first_name->value;
  4. $variables['lastname'] = $node->getOwner()->field_last_name->value;
  5. }

Comments

visabhishek's picture

From there we can use  {{ firstname }} and  {{lastname}} anywhere in your template.