Drupal - Change the Output of "Member for" on User Profiles


When viewing a user account profile page in Drupal, by default the "History" field is displayed like so:

Surprisingly after 7 years of Drupal development, no client has ever asked me to change this display, other than hiding it on occasion.

Changing how this is rendered is quite easy, just implement hook_user_view_alter(), and try something like this:

 * Implements hook_user_view_alter().
function my_module_user_view_alter(&$build) {
  $build['summary']['#title'] = '';
  $build['summary']['member_for']['#title'] = t('Member since');
  $build['summary']['member_for']['#markup'] = date('Y', $build['#account']->created);

This will render output like this:


No cording is necessary


Configuration / People / Account settings / Manage display

Setting "History" to "Hidden"

Add new comment