Hello,

I was wondering if anyone knows if it is possible to add the content profile field (ie first name) to the $user object so that it can be printed anywhere such as on page.tpl.php

I would appreciate the support!

Thank you

Comments

You can use theme preprocess functions to make data accessible to your theme templates.

A couple good starting places are:

i would like to know how to add content profile fields to $user object too...

anyone?

@jeffschuler: can you explain, please?

Thanks in advance!

something like this should work:

<?php
global $user;
$node_profile = content_profile_load(profile, $user->uid);
print
$node_profile->field_firstname[0]["value"];
?>

Try this:

/**
* implementation of hook_init()
*
* knows how to add profile node data to $user object
*/
function mymodule_init() {
  global $user;
  $user->profile = content_profile_load('profile', $user->uid);
}