function user_user_view

Same name in other branches
  1. 7.x modules/user/user.module \user_user_view()
  2. 9 core/modules/user/user.module \user_user_view()
  3. 10 core/modules/user/user.module \user_user_view()
  4. 11.x core/modules/user/user.module \user_user_view()

Implements hook_ENTITY_TYPE_view() for user entities.

File

core/modules/user/user.module, line 403

Code

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.