First of all, I am not a techie and have picked the codes mentioned below from various sources. I have added two new fields to the user profile - 'firstname' and 'surname'. I am using a custom theme and on one of the places (on a node), I need to display the real name (making some code changes) instead of the username.
I am replacing the existing code -
<h3><?php print $node->name ?></h3>
With this -
<h3><?php $profile = user_load($node->uid); $profile = user_view($profile); $firstname = render($profile['field_firstname']); $surname = render($profile['field_surname']); print $firstname.' '.$surname; ?></h3>
However, a strange thing is happening. I am able to print the surname correctly but the firstname is blank every time, even when I tried to print only the firstname (or the surname). Why is it that the firstname is not getting picked? What changes should I make?