On hook_form_alter setting select list options for a field By default select options i have left empty in admin of that content type. 

I am trying to alter select list option of a content type using hook_form_alter. 

I am setting the values to select values and is getting assigned.

Only issue is that its getting logged out with single refresh to create form of that content type form or try to submit that form. What am i doing wrong in the code.

Thanks in advance.   

function hook_form_alter(&amp;$form, &amp;$form_state, $form_id)
{
    if($form_id == 'product_node_form')
    {       

            $users = db_select('users', 'u');
            $users-&gt;join('users_roles','ur','u.uid = ur.uid');
            $users-&gt;fields('u',array('name'));
            $users-&gt;fields('ur',array('uid'));
            $users-&gt;condition('ur.rid',6,'=');
            $users-&gt;orderBy('u.uid');
            $users = $users-&gt;execute()-&gt;fetchAll();

            $vendor_list = array("Tan" =&gt; "Tan");

            foreach($users as $key =&gt; $user)
            {
                $vendor_list[$user-&gt;name] = $user-&gt;name;
            }
            $form['field_publish_to']['und']['#options'] = $vendor_list;
    }
}
Try to rename the variable $user/ $users. May be your code is overwriting the default $user object of drupal. Try after renaming the variables $user/ $users.