1.20.x user.module | user_build_content($account, $view_mode = 'full', $langcode = NULL) |
Builds a structured array representing the profile content.
Parameters
$account: A user object.
$view_mode: (optional) Display mode, e.g. 'full' or 'teaser'. Defaults to 'full'.
$langcode: (optional) A language code to use for rendering. Defaults to the global content language of the current request.
File
- modules/
user/ user.module, line 2309 - Enables the user registration and login system.
Code
function user_build_content($account, $view_mode = 'full', $langcode = NULL) {
if (!isset($langcode)) {
$langcode = $GLOBALS['language_content']->langcode;
}
// Remove previously built content, if exists.
$account->content = array();
// Allow modules to change the display 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 display mode is stored if no module has already
// populated the related key.
$account->content += array('#view_mode' => $view_mode);
}