User ID problem when programmatically creating nodes I have written a migration script that migrates data from Drupal 4.7 to Drupal 6. It is highly customized for my purposes. I am able to create new nodes with no problem. However, after I save the nodes I am noticing that the user that created it is showing up as "Anonymous" and in the database it has a uid of 0. Yet, when I wrote my code I have set it to 1 when the migrated user id has not been found. I have even double-checked to make sure that it is setting the uid to 1.

Why would this be setting it to uid = 0 when I specifically set it to 1?

  $node = new stdClass();
  $node-&gt;type = 'opinion_article';
  $node-&gt;title = $blog-&gt;title;
  $node-&gt;body = $blog-&gt;body;
  $node-&gt;teaser = $blog-&gt;teaser;

  //We need to associate the content to the user that created it.
  $node-&gt;uid = 1;
  $node-&gt;name = $account-&gt;name;
  $node-&gt;status = $blog-&gt;status;
  $node-&gt;comment = $blog-&gt;comment;
  $node-&gt;promote = $blog-&gt;promote;

  //Set a default topic of Migration Data.
  $node-&gt;field_topics[] = array('nid' =&gt; 820); ###### Remember to update this node ID to reflect the topic nid on dev once created. It is nid 916 on the dev server.  ################

  //Set the parent group
  $node-&gt;og_parent = $parent_nid;

  //Create the node
  $node = node_submit($node);
  node_save($node);
The problem is that node_submit() contains the following code.

  if (user_access('administer nodes')) {
    // Populate the "authored by" field.
    if ($account = user_load(array('name' =&gt; $node-&gt;name))) {
      $node-&gt;uid = $account-&gt;uid;
    }
    else {
      $node-&gt;uid = 0;
    }
  }


When it's not able to load the user object having $node-&gt;name as username, it sets the user ID to zero.
As you have already set the values for the node object, it is useless to pass the node to node_submit(); it would be better to just pass it to node_save().