function profile_user_view
Implements hook_user_view().
File
-
modules/
profile/ profile.module, line 328
Code
function profile_user_view($account) {
// Show private fields to administrators and people viewing their own account.
if (user_access('administer users') || $GLOBALS['user']->uid == $account->uid) {
$result = db_query('SELECT * FROM {profile_field} WHERE visibility <> :hidden ORDER BY category, weight', array(
':hidden' => PROFILE_HIDDEN,
));
}
else {
$result = db_query('SELECT * FROM {profile_field} WHERE visibility <> :private AND visibility <> :hidden ORDER BY category, weight', array(
':private' => PROFILE_PRIVATE,
':hidden' => PROFILE_HIDDEN,
));
}
$fields = array();
foreach ($result as $field) {
if ($value = profile_view_field($account, $field)) {
$title = $field->type != 'checkbox' ? check_plain($field->title) : NULL;
// Create a single fieldset for each category.
if (!isset($account->content[$field->category])) {
$account->content[$field->category] = array(
'#type' => 'user_profile_category',
'#title' => $field->category,
);
}
$account->content[$field->category][$field->name] = array(
'#type' => 'user_profile_item',
'#title' => $title,
'#markup' => $value,
'#weight' => $field->weight,
'#attributes' => array(
'class' => array(
'profile-' . $field->name,
),
),
);
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.