How can I get access to a custom profile field in my page.tpl.php? I am hoping to display a user name I pull down from LDAP and this seems to be the only option but I cannot seem to get it to print..

Comments

heytrish’s picture

Place the following into your page.tpl.php or anywhere for that matter. Copy/paste and don't forget to remove the spaces in < ?php and < ?

< ?php
global $user;
$user = user_load(array('uid' => $user->uid));

if ($user->uid) : ?>
    <div class="helloworld">Hello < ?php print $user->profile_firstname; ?> </div> 
  < ?php else : ?>
    <div class="helloworld">Howdy Stranger</div>
  < ?php endif; ?>

output if you are logged in:

    Hello Bunnies

output if the user is not logged in:

    Howdy Stranger
cridenour’s picture

user_load() is what I need. :-)

Thank you very much.