Fix for Using hook_form_alter to fill in cck fields automatically and then hiding them from users

function sitehelper_form_alter($form_id, &$form) {
   global $user;
   switch ($form_id) {

   // Only do this for the review type's form
   case 'minfo_node_form':
      // Get the parent node's id from the url (url created from a different node)
      if(arg(1) == 'add') {
         $pnid = $_GET['pnid'];
         $newpnid = intval($pnid);
         $pnode = node_load($newpnid);
         // Set the parentnid field's value
         $form['field_parentnid'][0]['value']['#value'] = $newpnid;
      }
     
      if($user->uid != '1') {
         // Hide the field
         $form['field_parentnid'][0]['value']['#access'] = FALSE;
      }
   break;
   }
}

Submit Fix

Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Select the syntax highlighting mode to use.