Internet Commons

Your website development partner

Controls: show



[log in] or [register] to leave a comment for this document.

Go to: all documents

Options: show



[home] [about] [help]




User profile view state transitions

20-Apr-2013 [211]

Initial state: user object loaded with user_load(). Field extensions are omitted without the user_load call.

(object) array(
  'uid' => '2',
  'name' => '<name>',
  'pass' => '<encrypted password>',
  'mail' => '<email address>',
  'theme' => '',
  'signature' => '',
  'signature_format' => 'plain_text',
  'created' => '1365031416',
  'access' => '1366473346',
  'login' => '1366249131',
  'status' => '1',
  'timezone' => 'America/New_York',
  'language' => 'en',
  'picture' => '0',
  'init' => '<initial email address>',
  'data' => array(
    'mimemail_textonly' => 0,
  'roles' => array(
    2 => 'authenticated user',
    3 => 'Website developer',
// field extensions example
  'field_business_affiliation_type' => array(
    'und' => array(
        'value' => '0',
  'field_contractor' => array(),
  'field_account' => array(),
Name Description
hook_user_view($account, $view_mode, $langcode) The user's account information is being displayed.
hook_user_view_alter(&$build) The user was built; the module may modify the structured content. This is the recommended place to alter user profile, set to be output by theme(), qualified by #theme, or qualified by #type through element_info.

Drupal functions and related hooks:

user_view_page($account) Page callback wrapper for user_view()
user_view($account, $view_mode = 'full', $langcode = NULL) Generate an array for rendering the given user; calls drupal_alter(array('user_view', 'entity_view'), $build, $type); to allow modules to make changes
user_field_extra_fields() implements hook_field_extra_fields
user_user_presave(&$edit, $account, $category) Implements hook_user_presave
user_user_categories() Implements hook_user_categories
user_element_info() Implements hook_element_info()
user_user_view($account) Implements hook_user_view
user_account_form(&$form, &$form_state) Helper function to add default user account fields to user registration and edit form. see user_account_form_validate(), user_validate_current_pass(), user_validate_picture(), user_validate_mail()
element_info($type) Retrieves the default properties for the defined element type.$type: An element type as defined by hook_element_info().
user_build_content($account, $view_mode = 'full', $langcode = NULL) Builds a structured array representing the profile content
drupal_render(&$elements) Renders HTML given a structured array tree. Recursively iterates over each of the array elements, generating HTML code.
drupal_render_children(&$element, $children_keys = NULL)
element_children(&$elements, $sort = FALSE)
drupal_alter($type, &$data, &$context1 = NULL, &$context2 = NULL, &$context3 = NULL)
hook_entity_view_alter(&$build, $type)

system_element_info sets numerous element default behaviours, that are merged from drupal_render(). For example system.module/system_element_info implements

  $types['markup'] = array(
    '#markup' => '',
    '#pre_render' => array('drupal_pre_render_markup'),

This is used to process #markup set to 'markup'.

User Hooks

... not related to user display

Here's a set of hooks (transition triggers) available for the user object, that aren't used for user display.

See User hook Functions.

Name Description
hook_user_cancel($edit, $account, $method) Act on user account cancellations.
hook_user_cancel_methods_alter(&$methods) Modify account cancellation methods.
hook_user_categories() Retrieve a list of user setting or profile information categories.
hook_user_delete($account) Respond to user deletion.
hook_user_insert(&$edit, $account, $category) A user account was created.
hook_user_load($users) Act on user objects when loaded from the database.
hook_user_login(&$edit, $account) The user just logged in.
hook_user_logout($account) The user just logged out.
hook_user_operations() Add mass user operations.
hook_user_presave(&$edit, $account, $category) A user account is about to be created or updated.
hook_user_role_delete Inform other modules that a user role has been deleted.
hook_user_role_insert($role) Inform other modules that a user role has been added.
hook_user_role_presave($role) Inform other modules that a user role is about to be saved.
hook_user_role_update($role) Inform other modules that a user role has been updated.
hook_user_update(&$edit, $account, $category) A user account was updated.

Only hook_user_view is involved with user_display

User Functions

... not related to user display

Name Description
user_load($uid, $reset = FALSE) A fully-loaded user object upon successful user load, or FALSE if the user cannot be loaded.