By eyos on
Hello,
I would like to display the profile fields profile_firstname and profile_lastname in my page.tpl.php whenever a user is logged in. I 've read several posts about displaying and using profile fields, but can't get it to work.
Currenty, this is in the top of page.tpl.php:
<?php
global $user;
profile_load_profile($user->uid);
//print "<code>" . var_export($user, true) . "";
?>
This is in the right section of page.tpl.php:
<?php
$username = check_plain($user->name);
$profile = profile_view_profile($user);
print profile_view_field($user, 'profile_firstname');
print $user->profile_firstname;
?>
As you can see, it tested several ways of outputting the profile field. However, it doesn't work! Any thoughts on what am I doing wrong?
Comments
Easy fix
You need to change
profile_load_profile($user->uid);toprofile_load_profile($user);Great, that's it! It works
Great, that's it! It works now. Thank you very much!