hook_form_alter() and hook_nodeapi() to alter fields and insert additional data on insert I have the code below, and I want to update the fields on my node using hook_nodeapi(). How do I set the fields on insert?

/*
 * Implements hook_form_alter().
 */

function feature_contact_form_form_alter(&amp;$form, $form_state, $form_id) { 
  if ($form_id == 'contact_form_node_form') {
    $form['field_user_agent']['#type'] = 'hidden';
    $form['field_ip_address']['#type'] = 'hidden';
    $form['buttons']['submit']['#weight'] = 1;
  }
}

/*
 * Implements hook_nodeapi().   
 */
function feature_contact_form_nodeapi(&amp;$node, $op, $a3 = NULL, $a4 = NULL) {
  if ($node-&gt;type == 'contact_form') {
    if ($op == 'insert') {
      function getRealIpAddr() {
        if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
          $ip = $_SERVER['HTTP_CLIENT_IP'];
        }
        elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
          $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
        }
        else {
          $ip = $_SERVER['REMOTE_ADDR'];
        }
        return $ip;
      }

      $ipaddress = getRealIpAddr($ip);
      $node-&gt;field_user_agent = array($ipaddress);
      $node-&gt;field_ip_address = array($_SERVER['HTTP_USER_AGENT']);
    }
  }
}
As mentioned in the comments any extra fields you add to to a node form won't automatically be persisted to the database, the node module only takes care of the fields that it knows about.

Traditionally there are 2 options:


Use CCK instead and add fields to the node that way. Then you don't need to take care of data storage/loading yourself.
Add your own table for data storage using hook_schema(), making sure you have a column for nid (node id). Then in hook_nodeapi() use the insert and update ops to run a db_query() to insert/update the data in that table for the current node.

Then you just need to load that data back from the DB on to the $node object in the load op of hook_nodeapi(). Your data will then be available at $node-&gt;field_name when you have a node object loaded with node_load().