Notice: Undefined index: main_profile in include() (line 54 global $user;  
$user-&gt;uid ;
print_r($user-&gt;uid);
print "print out the user value" . $user-&gt;uid;

$uid =3;

$account = user_load($user-&gt;uid); 

$profile = profile2_load_by_user($account);

$print_first_name =  drupal_render(field_view_field('profile2',$profile['main_profile'], 'field_first_name'));
print $print_first_name;


What I have attempted to do is to pass the $user-&gt;uid to the user_load function.
When I pass $uid = 3 to the user_load function it seems to work fine. I am wondering what approach I should try to fix this problem. 

error message:

EntityMalformedException: Missing bundle property on entity of type profile2. in entity_extract_ids() (line 7562 of /home/td6/public_html//includes/common.inc).
Your mistakes is here main_profile , profile type always start with profile_name . just need change main_profile to profile_main

global $user;  
$user-&gt;uid ;
print_r($user-&gt;uid);
print "print out the user value" . $user-&gt;uid;

$uid =3;

$account = user_load($user-&gt;uid); 
$profile = profile2_load_by_user($account);


$print_first_name =  drupal_render(field_view_field('profile2',$profile['profile_main'], 'field_first_name'));
print $print_first_name;


If you want see all your profile type and correct name and it's contents print_r or var_dump $profile

$profile = profile2_load_by_user($account);
print_r($profile);