1

This question already has an answer here:

I want to show the user, his/her email address on their "My Account" Page. I am not using any modules for the registration page, but just the default Drupal 7 registration fields.

How can i display user name and email address fields to the user on "My Account Page"?

marked as duplicate by Neograph734, sanzante, Shawn Conn, Yusef Mohamadi, DRUPWAY Mar 14 '17 at 6:15

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • what is the purpose of the last tag you used? – Pierre.Vriens Mar 13 '17 at 19:50
  • @Pierre.Vriens it has been removed :) – Neograph734 Mar 13 '17 at 22:35
  • 1
    That same technique can be used for adding a username within the same template file. Use $profile_user->name instead. – Neograph734 Mar 13 '17 at 22:40
0

You will need to create a custom module to achieve that functionality.

If you want to override tabs in view page

function mymodule_menu_alter(&$items) {
  $items['user/%user/view']['title'] = t('My account');
  $items['user/%user/edit']['title'] = t('Edit account information');
}

If you was to display additional info in view page

function mymodule_user_view($account, $view_mode, $langcode) {
  // hide unwanted fields
  hide($account->content['summary']['member_for']);
  hide($account->content['summary']['blog']);
  hide($account->content['user_picture']);

  // add information  
  $account->content['summary']['#title'] = t('My Account');
  $account->content['summary']['personal'] = array(
    '#type' => 'user_profile_item', 
    '#title' => t('Personal'), 
    '#markup' => get_profile_details($account), 
    '#weight' => -100, 
  );
  $account->content['summary']['login'] = array(
    '#type' => 'user_profile_item', 
    '#title' => t('Login'), 
    '#markup' => get_profile_details($account, 'login'), 
    '#weight' => -99, 
  );
}

This function returns details in list. Feel free to add/delete details based on your requirements

function get_profile_details($account, $view = 'personal') {
  // profile details
  $items = array();
  switch($view) {
    case 'personal':
      if($account->picture) {
        $items[] = theme('image_style', array('path' => $account->picture->uri, 'style_name' => 'thumbnail'));
      }
      $items[] = t('Name: ').$account->field_account_first_name['und'][0]['value'].' '.$account->field_account_last_name['und'][0]['value'];
      $items[] = t('Email: ').l($account->mail, 'mailto:'.$account->mail);
      $roles = array();
      foreach($account->roles as $role) {
        if($role != 'authenticated user') {
          $roles[] = ucwords($role);
        }
      }
      if(count($roles) > 0) {
        $items[] = t('Role: ').implode(', ', $roles);
      }
      else {
        $items[] = t('Role: ').t('General user');
      }
    break;
    case 'login':
      $items[] = t('Username: ').$account->name;
      $items[] = t('Timezone: ').$account->timezone;
      $items[] = t('Member since: ').format_interval(REQUEST_TIME - $account->created);
      $items[] = t('Last login: ').format_interval(REQUEST_TIME - $account->access);
    break;
  }
  return theme('item_list', array('items' => $items));
}

Let me know if you need any help

Not the answer you're looking for? Browse other questions tagged or ask your own question.