function user_build_content
Builds a structured array representing the profile content.
Parameters
$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.
1 call to user_build_content()
- user_view in modules/
user/ user.module - Generate an array for rendering the given user.
File
-
modules/
user/ user.module, line 2729
Code
function user_build_content($account, $view_mode = 'full', $langcode = NULL) {
if (!isset($langcode)) {
$langcode = $GLOBALS['language_content']->language;
}
// Remove previously built content, if exists.
$account->content = array();
// Allow modules to change the view mode.
$view_mode = key(entity_view_mode_prepare('user', array(
$account->uid => $account,
), $view_mode, $langcode));
// Build fields content.
field_attach_prepare_view('user', array(
$account->uid => $account,
), $view_mode, $langcode);
entity_prepare_view('user', array(
$account->uid => $account,
), $langcode);
$account->content += field_attach_view('user', $account, $view_mode, $langcode);
// Populate $account->content with a render() array.
module_invoke_all('user_view', $account, $view_mode, $langcode);
module_invoke_all('entity_view', $account, 'user', $view_mode, $langcode);
// Make sure the current view mode is stored if no module has already
// populated the related key.
$account->content += array(
'#view_mode' => $view_mode,
);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.