I'm using an implementation of hook_user to create a custom node during user registration, and to set a few CCK fields. One field that I wanted was a User Reference to the newly registering user's profile. However, within a module trying something like
// ...
$node['field_user_reference'] = array(array('uid' => $node->uid ));
// ...
$node = node_submit($node);
node_save($node);
doesn't set the user reference. As far as I know, this stems from CCK using the FormAPI and it only accepts inputs from its form.
However, I've had some success with the Link module. I can use
// ...
$node['field_newlink'] = array( // field_newlink is a Link module type
array('url' => $lnk ),
array('title' => 'Some Dude'),
array('attributes' => 'N'),
);
// ...
$node = node_submit($node);
node_save($node);
and I get the link (but without the title, it shows say http://localhost/drupal/user/20 ).
I assume that this is a similar FormAPI situation.
If anyone has any ideas to help me to get the link title working, that'd be great.
Or, perhaps I've missed something and I don't need to use the Link module.
Is there a way to programatically set a CCK user reference?
Comments
Comment #1
dqd... since this issue is 3 years old ... o.O