not able to display the real name of the users 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 - 

&lt;h3&gt;&lt;?php print $node-&gt;name ?&gt;&lt;/h3&gt;


With this - 

&lt;h3&gt;&lt;?php 
     $profile = user_load($node-&gt;uid); 
     $profile = user_view($profile); 
     $firstname = render($profile['field_firstname']); 
     $surname = render($profile['field_surname']); 
     print $firstname.' '.$surname; ?&gt;&lt;/h3&gt;


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?
Did you try real name module before write your own code?

I did not use 6.x version, but i guess it will be more flexible than your solution.