in drupal 7, how to add user pic and name to the user menu when logged in? In drupal 7, there are default blocks such as user menu block and login block, the user menu block are especially working for the logged in user while login block are working for non logged in user.

the user menu block contains the static user menu with account, profile, logout menu item, however what I want to do is when the user logged in, the user menu can have additional menu item showing the user pic and name.

I know this could be done by making a new block with php code, but I just want to know if I want to use the existing user menu block, what and how I should change it?
In Drupal 7, you can implement hook_block_view_alter() to alter the content of a block defined from another module. For example, menu_block_view_alter() is an implementation of that hook done by the Menu module.

function menu_block_view_alter(&amp;$data, $block) {
  // Add contextual links for system menu blocks.
  if ($block-&gt;module == 'system' &amp;&amp; !empty($data['content'])) {
    $system_menus = menu_list_system_menus();
    if (isset($system_menus[$block-&gt;delta])) {
      $data['content']['#contextual_links']['menu'] = array('admin/structure/menu/manage', array($block-&gt;delta));
    }
  }
}


$data is the array defined from the implementation of hook_block_view(), and it contains two array indexes:


"subject": the default localized title of the block
"content": the content of the block's body


In Drupal 7, $data['content'] could be either a string containing HTML code, or an array as accepted from drupal_render().

$block is an object containing all the data about the block loaded from the database. You can at least count on two elements:


"module": the name of the module implementing the block
"delta": the identifier for the block used from the module implementing it


If you just need to alter one single block, you can consider implementing hook_block_view_MODULE_DELTA_alter(), which is the equivalent of hook_form_FORM_ID_alter() of hook_form_alter(). Replace MODULE with the module name, and DELTA with the identifier for the block.
The hook gets the same parameters as hook_block_view_alter().