hook_insert

5 node.php hook_insert($node)
6 node.php hook_insert($node)
7 node.api.php hook_insert($node)
8 node.api.php hook_insert(Drupal node Node $node)

Respond to creation of a new node.

This hook is invoked only on the module that defines the node's content type (use hook_node_insert() to act on all node insertions).

This hook is invoked from node_save() after the node is inserted into the node table in the database, before field_attach_insert() is called, and before hook_node_insert() is invoked.

Parameters

Drupal\node\Node $node: The node that is being created.

Related topics

57 functions implement hook_insert()

1 invocation of hook_insert()

File

core/modules/node/node.api.php, line 1145
Hooks provided by the Node module.

Code

function hook_insert(Drupal node Node $node) {
  db_insert('mytable')
    ->fields(array(
    'nid' => $node->nid, 
    'extra' => $node->extra,
  ))
    ->execute();
}
Login or register to post comments