Pull values from Drupal User Profile to CCK fields

  • Published by steve on 4 February 2012.

Surprisingly hard to find, certain snippets floating around on the web do not work for specific versions of CCK. So far these are foolproof with Drupal 6.

global $user;
return array(0=> array('value' => $user->uid));

global $user;
return array(0=> array('value' => $user->name));

global $user;
$account = user_load(array('uid' => $user->uid));
return array(
0 => array('value' => $account->profile_commloc),
);

global $user;
return array(0 => array('value' => $user->mail));