4.6.x node.module node_submit(&$node)
4.7.x node.module node_submit($node)
5.x node.module node_submit($node)
6.x node.module node_submit($node)
7.x node.module node_submit($node)

Prepares a node for saving by populating teaser, author, and creation date.


object|array $node: A node object or array.

Return value

A validated node object with a populated teaser, author, and creation date.

3 calls to node_submit()
blogapi_blogger_edit_post in modules/blogapi/blogapi.module
Blogging API callback. Modifies the specified blog node.
blogapi_blogger_new_post in modules/blogapi/blogapi.module
Blogging API callback. Inserts a new blog post as a node.
node_form_submit_build_node in modules/node/node.pages.inc
Build a node by processing submitted form values and prepare for a form rebuild.


modules/node/node.module, line 833
The core that allows content to be submitted to the site. Modules and scripts may programmatically submit nodes using the usual form API pattern.


function node_submit($node) {
  global $user;

  // Convert the node to an object, if necessary.
  $node = (object) $node;

  // Generate the teaser, but only if it hasn't been set (e.g. by a
  // module-provided 'teaser' form item).
  if (!isset($node->teaser)) {
    if (isset($node->body)) {
      $node->teaser = node_teaser($node->body, isset($node->format) ? $node->format : NULL);

      // Chop off the teaser from the body if needed. The teaser_include
      // property might not be set (eg. in Blog API postings), so only act on
      // it, if it was set with a given value.
      if (isset($node->teaser_include) && !$node->teaser_include && $node->teaser == substr($node->body, 0, strlen($node->teaser))) {
        $node->body = substr($node->body, strlen($node->teaser));
    else {
      $node->teaser = '';
      $node->format = 0;
  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;
  $node->created = !empty($node->date) ? strtotime($node->date) : time();
  $node->validated = TRUE;
  return $node;


markj’s picture

If you're programmatically creating nodes, be sure to populate $node->name, since the block starting at "if (user_access('administer nodes'))" in node_submit() will change your $node->uid to 0 (anonymous) for all users who have 'administer nodes' permissions, including your admin user.

oskar_calvo’s picture

If you have problems when you update nodes with node_submit and node save because the created dates is change please read this post from drupal.org


You must make this:

$node = node_load($this_product_name_id);
// do some stuff here
$node->date = format_date($node->created, 'custom', 'Y-m-d H:i:s O');
$node = node_submit($node);
if ($node->validated) {

Thanks Berto.