Same name and namespace in other branches
- 4.6.x developer/hooks/node.php \hook_insert()
- 4.7.x developer/hooks/node.php \hook_insert()
- 5.x developer/hooks/node.php \hook_insert()
- 6.x developer/hooks/node.php \hook_insert()
Respond to creation of a new node.
This is a node-type-specific hook, which is invoked only for the node type being affected. See Node API hooks for more information.
Use hook_node_insert() to respond to node insertion of all node types.
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
$node: The node that is being created.
Related topics
43 functions implement hook_insert()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- ajax_command_insert in includes/
ajax.inc - Creates a Drupal Ajax 'insert' command using the method in #ajax['method'].
- book_node_insert in modules/
book/ book.module - Implements hook_node_insert().
- comment_node_insert in modules/
comment/ comment.module - Implements hook_node_insert().
- comment_node_type_insert in modules/
comment/ comment.module - Implements hook_node_type_insert().
- db_insert in includes/
database/ database.inc - Returns a new InsertQuery object for the active database.
1 invocation of hook_insert()
- field_attach_insert in modules/
field/ field.attach.inc - Save field data for a new entity.
File
- modules/
node/ node.api.php, line 1172 - Hooks provided by the Node module.
Code
function hook_insert($node) {
db_insert('mytable')
->fields(array(
'nid' => $node->nid,
'extra' => $node->extra,
))
->execute();
}