Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. UserHooks.php

function UserHooks::userView

Implements hook_ENTITY_TYPE_view() for user entities.

File

core/modules/user/src/Hook/UserHooks.php, line 170

Class

UserHooks
Hook implementations for user.

Namespace

Drupal\user\Hook

Code

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

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal