hook_node_insert

  1. drupal
    1. 8
    2. 7
Versions
7 – 8 hook_node_insert($node)

Respond to creation of a new node.

This hook is invoked from node_save() after the node is inserted into the node table in the database, after the type-specific hook_insert() is invoked, and after field_attach_insert() is called.

Parameters

$node The node that is being created.

Related topics

Code

modules/node/node.api.php, line 510

<?php
function hook_node_insert($node) {
  db_insert('mytable')
    ->fields(array(
    'nid' => $node->nid, 
    'extra' => $node->extra,
  ))
    ->execute();
}
?>