I need to get results from
"PHP code" in "Default value" section in Node reference.

when I run in dev "Execute PHP Code" script like that:

global $user;
$venue = content_profile_load('jobseeker_profile', $user->uid);
dpm ($venue->field_profile_first_name[0]['value']);

or

global $user;
$venue = content_profile_load('jobseeker_profile', $user->uid);
return ($venue->field_profile_first_name[0]['value']);

it gives me a result in message area with no problem.

But if I put in "PHP code" in "Default value" section

global $user;
$venue = content_profile_load('jobseeker_profile', $user->uid);
return array(
   0 => array('value' => $venue->field_profile_first_name[0]['value']),
);

or

global $user;
$venue = content_profile_load('jobseeker_profile', $user->uid);
return array(
   0 => array('nid' => $venue->field_profile_first_name[0]['nid']),
);

then I get empty result, no strings.

I tried also that with no success:

$refnid = node_load(array('type'=>'jobseeker_profile', 'uid'=>$node->uid));
return array(
    0 => array('nid' => $refnid->nid )
);

Comments

clashar’s picture

could anyone help?

gluebox’s picture

This is more as a breadcrumb for myself, or others that find this node. Here's the code I used to prefill a CCK field form the current user's profile.

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

(Remove the PHP open/close tags)

clashar’s picture

Status: Active » Closed (works as designed)

.gluebox, thank you!
I don't use anymore D6 and can't check your solution, but I hope it could help someone else)