Download & Extend

How can you set the default value for user reference field to the current logged in user?

Project:Content Construction Kit (CCK)
Version:6.x-2.x-dev
Component:userreference.module
Category:support request
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

I am trying to set a user reference field on a node to have a default value of the currently logged in user. I have tried the following hook_form_alter method but I am not getting anything to populate as the default value (in fact the whole user reference field disappears) .

function modulename_form_equipment_node_form_alter(&$form, &$form_state) {
 
$form['field_test_reference'][0]['#default_value'] = $user->uid;

}

Any suggestions on how this can be accomplished?

Comments

#1

$form['#node']->field_test_reference[0]['nid'] = $nid;

may help u

nobody click here