Theming with Profile2

Public

User-profile.tpl.php
If you are designing a custom template for your user profile pages and are using the Profile2 module, you probably are looking to add your custom fields to the user-profile.tpl.php template. Here is how this can be accomplished.

This assumes that you have a Profile2 profile type called my-profile. You may easily load your fields into your custom user-profile.tpl.php by printing them like this:

Get raw version
php
  1. <?php print render($user_profile['profile_my-profile']['view']['profile2'][1]['field_example']); ?>
  2.  
  3. <?php
  4. $uid = user_load($node->uid);
  5. $myprofile = profile2_load_by_user($uid, 'my-profile');
  6. ?>
  7.  
  8. <?php
  9. $uid = user_load($node->uid);
  10. $myprofile = profile2_load_by_user($uid, 'my-profile');
  11. ?>