Skip to main content
added 12 characters in body
Source Link
Yuseferi
  • 22.2k
  • 22
  • 118
  • 218

Your mistakes is here main_profile is mistakemain_profile , profile type always start with profile_name . just need change main_profile to profile_main

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

$uid =3;

$account = user_load($user->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);

Your mistakes is here main_profile is mistake , profile type always start with profile_name . just need change main_profile to profile_main

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

$uid =3;

$account = user_load($user->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 print_r $profile

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

Your mistakes is here main_profile , profile type always start with profile_name . just need change main_profile to profile_main

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

$uid =3;

$account = user_load($user->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);

Your mistakes is here main_profile is mistake , profile type always start with profile_name . just need change main_profile to profile_main global $user;
$user->uid ; print_r($user->uid); print "print out the user value" . $user->uid;

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

$uid =3;

$account = user_load($user->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;

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

If you wnatwant see all your profile type and correct name print_r $profile

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

Your mistakes is here main_profile is mistake , profile type always start with profile_name . just need change main_profile to profile_main global $user;
$user->uid ; print_r($user->uid); print "print out the user value" . $user->uid;

$uid =3;

$account = user_load($user->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 wnat see all your profile type and correct name print_r $profile

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

Your mistakes is here main_profile is mistake , profile type always start with profile_name . just need change main_profile to profile_main

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

$uid =3;

$account = user_load($user->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 print_r $profile

$profile = profile2_load_by_user($account);
print_r($profile);
Source Link
Yuseferi
  • 22.2k
  • 22
  • 118
  • 218

Your mistakes is here main_profile is mistake , profile type always start with profile_name . just need change main_profile to profile_main global $user;
$user->uid ; print_r($user->uid); print "print out the user value" . $user->uid;

$uid =3;

$account = user_load($user->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 wnat see all your profile type and correct name print_r $profile

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