How to get profile fields in Drupal 7. Profile fields are made with Profile2 module.
About Profile2 Module
Profile2 module is designed to be the successor of the core profile module, which is deprecated for Drupal 7. In contrast to the deprecated module this module provides a new, fieldable 'profile' entity - leverage the power of fields!You can create profile field groups and give roles permissions to own those groups.
Display the fields
Source code viewer
// Current user information - needed for id. global $user; // Define pid(profile id) variable. static $pid; // Query to get pid. $result = db_query('select pid from profile where uid = '.$user->uid); // Get pid. foreach ($result as $record) { $pid = $record->pid; } // Load profile fields. $profile = profile2_load($pid); // Print profile array. // OR global $user; $profile2 = profile2_load_by_user($user); $profile = $profile2['main']; // Pretty print profile object using devel module. dpm($profile);Programming Language: PHP