Change the default value of the node reference via hook_alter_form field_userid is a user reference field with an autocomplete widget

i want to set the default value of this field, but the code below doesn't work

Does anyone can help me?

Thank you very much! 

 function mymodule_form_node_form_alter(&amp;$form, &amp;$form_state, $form_id)
    {
        global $user;


        if($form['#node']-&gt;type=="article")
        {   

            $form['#after_build'][]='mymodule_after_build';     


        }
    }

    function mymodule_after_build($form, &amp;$form_state)
    {
        global $user;   

        $form['field_userid']['#default_value'][0]['uid']=$user-&gt;uid;

        return $form;
    }
I can't think of any reason why your code would need to be in an after_build function, you would usually put it straight into the form alter hook. At the moment you've got the array keys the wrong way round. Without being able to see the structure of your form it's difficult to say exactly where the correct element is, but one of these should work:

function mymodule_form_node_form_alter(&amp;$form, &amp;$form_state, $form_id) {
  global $user;

  // Try this one
  $form['field_userid'][LANGUAGE_NONE][0]['#default_value'] = $user-&gt;uid;

  // Or this one
  $form['field_userid'][LANGUAGE_NONE][0]['uid']['#default_value'] = $user-&gt;uid;
}