Skip navigation
Help

hook_node_insert

7 node.api.php 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

18 functions implement hook_node_insert()

File

drupal/modules/node/node.api.php, line 510
Hooks provided by the Node module.

Code

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