8.5.x user.module user_view($account, $view_mode = 'full', $langcode = NULL)
8.0.x user.module user_view($account, $view_mode = 'full', $langcode = NULL)
8.1.x user.module user_view($account, $view_mode = 'full', $langcode = NULL)
8.2.x user.module user_view($account, $view_mode = 'full', $langcode = NULL)
8.3.x user.module user_view($account, $view_mode = 'full', $langcode = NULL)
8.4.x user.module user_view($account, $view_mode = 'full', $langcode = NULL)
8.6.x user.module user_view($account, $view_mode = 'full', $langcode = NULL)
4.6.x user.module user_view($uid = 0)
4.7.x user.module user_view($uid = 0)
5.x user.module user_view($uid = 0)
6.x user.pages.inc user_view($account)
7.x user.module user_view($account, $view_mode = 'full', $langcode = NULL)

Generate an array for rendering the given user.

When viewing a user profile, the $page array contains:

  • $page['content']['Profile Category']: Profile categories keyed by their human-readable names.
  • $page['content']['Profile Category']['profile_machine_name']: Profile fields keyed by their machine-readable names.
  • $page['content']['user_picture']: User's rendered picture.
  • $page['content']['summary']: Contains the default "History" profile data for a user.
  • $page['content']['#account']: The user account of the profile being viewed.

To theme user profiles, copy modules/user/user-profile.tpl.php to your theme directory, and edit it as instructed in that file's comments.


$account: A user object.

$view_mode: View mode, e.g. 'full'.

$langcode: (optional) A language code to use for rendering. Defaults to the global content language of the current request.

Return value

An array as expected by drupal_render().

1 call to user_view()
user_view_page in modules/user/user.module
Page callback wrapper for user_view().
3 string references to 'user_view'
TriggerUserTokenTestCase::testUserTriggerTokenReplacement in modules/trigger/trigger.test
Tests a variety of token replacements in actions.
trigger_test_action_info in modules/trigger/tests/trigger_test.module
Implements hook_action_info().
trigger_user_view in modules/trigger/trigger.module
Implements hook_user_view().


modules/user/user.module, line 2651
Enables the user registration and login system.


function user_view($account, $view_mode = 'full', $langcode = NULL) {
  if (!isset($langcode)) {
    $langcode = $GLOBALS['language_content']->language;

  // Retrieve all profile fields and attach to $account->content.
  user_build_content($account, $view_mode, $langcode);
  $build = $account->content;

  // We don't need duplicate rendering info in account->content.
  $build += array(
    '#theme' => 'user_profile',
    '#account' => $account,
    '#view_mode' => $view_mode,
    '#language' => $langcode,

  // Allow modules to modify the structured user.
  $type = 'user';
  ), $build, $type);
  return $build;