You are here

function profile2_user_view in Profile 2 7

Same name and namespace in other branches
  1. 7.2 profile2.module \profile2_user_view()

Implements hook_user_view().

File

./profile2.module, line 399
Support for configurable user profiles.

Code

function profile2_user_view($account, $view_mode, $langcode) {
  foreach (profile2_get_types() as $type => $profile_type) {
    if ($profile_type->userView && ($profile = profile2_load_by_user($account, $type))) {
      if (profile2_access('view', $profile)) {
        $account->content['profile_' . $type] = array(
          '#type' => 'user_profile_category',
          '#title' => $profile_type
            ->getTranslation('label'),
          '#prefix' => '<a id="profile-' . $profile->type . '"></a>',
        );
        $account->content['profile_' . $type]['view'] = $profile
          ->view($view_mode);
      }
    }
  }
}