Skip to main content
added 3 characters in body
Source Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284

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' => $node->name))) {
      $node->uid = $account->uid;
    }
    else {
      $node->uid = 0;
    }
  }

When it's not able to load the user object having $node->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().

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' => $node->name))) {
      $node->uid = $account->uid;
    }
    else {
      $node->uid = 0;
    }
  }

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

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' => $node->name))) {
      $node->uid = $account->uid;
    }
    else {
      $node->uid = 0;
    }
  }

When it's not able to load the user object having $node->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().

Source Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284

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' => $node->name))) {
      $node->uid = $account->uid;
    }
    else {
      $node->uid = 0;
    }
  }

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