function user_user_view

user_user_view(array &$build, UserInterface $account, EntityViewDisplayInterface $display)

Implements hook_ENTITY_TYPE_view() for user entities.

File

core/modules/user/user.module, line 370
Enables the user registration and login system.

Code

function user_user_view(array &$build, UserInterface $account, EntityViewDisplayInterface $display) {
  if ($display->getComponent('member_for')) {
    $build['member_for'] = array(
      '#type' => 'item',
      '#markup' => '<h4 class="label">' . t('Member for') . '</h4> ' . \Drupal::service('date.formatter')->formatTimeDiffSince($account->getCreatedTime()),
    );
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!user!user.module/function/user_user_view/8.1.x