I'm using CCK and Node Profile, and I'm trying to figure out the php code to pull a default value from another field that users would have filled in previously. This is the code that I've gotten so far:

global $user;
$desired_result = db_query("SELECT field_value FROM {content_type_table} INNER JOIN node ON (content_type_table.nid = node.nid) WHERE (node.uid =  $user->uid)");
return array(
array(
  'value' => print $desired_result
)
);

The problem is that it only returns the number 1 no matter how I tweak this code. Does anyone know where I'm going wrong?

Comments

skassam’s picture

I just satisfied the need for this myself. I did the following:

global $user;
$profile_data = profile_view_profile($user);

//"Mailing Address" is the Profile Category
//"profile_ma_street" is the profile field name
$user_profile_data = $profile_data['Mailing Address']['profile_ma_street']['value'];

$user_profile_array = array( array('value' => $user_profile_data) );

return $user_profile_array;

I hope that helps someone.

pancho’s picture

Status: Active » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

cgjohnson’s picture

THANK YOU