function hook_node_insert

×

Error message

User warning: The following module is missing from the file system: theme/theme. For information about how to fix this, see the documentation page. in _drupal_trigger_error_with_delayed_logging() (line 1156 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
cis7 node.api.php hook_node_insert($node)
cle7 node.api.php hook_node_insert($node)
elmsmedia7 node.api.php hook_node_insert($node)
icor7 node.api.php hook_node_insert($node)
meedjum_blog7 node.api.php hook_node_insert($node)
mooc7 node.api.php hook_node_insert($node)

Respond to creation of a new node.

This hook is invoked from node_save() after the database query that will insert the node into the node table is scheduled for execution, after the type-specific hook_insert() is invoked, and after field_attach_insert() is called.

Note that when this hook is invoked, the changes have not yet been written to the database, because a database transaction is still in progress. The transaction is not finalized until the save operation is entirely completed and node_save() goes out of scope. You should not rely on data in the database at this time as it is not updated yet. You should also note that any write/update database queries executed from this hook are also not committed immediately. Check node_save() and db_transaction() for more info.

Parameters

$node: The node that is being created.

Related topics

21 functions implement hook_node_insert()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

book_node_insert in modules/book/book.module
Implements hook_node_insert().
book_title_override_node_insert in sites/all/modules/elmsln_contrib/book_title_override/book_title_override.module
Implements hook_node_insert().
cis_section_node_insert in sites/all/modules/elmsln_contrib/cis_connector/features/cis_section/cis_section.module
Implements hook_node_insert().
comment_node_insert in modules/comment/comment.module
Implements hook_node_insert().
devel_generate_node_insert in sites/all/modules/ulmus/devel/devel_generate/devel_generate.module
Inserts nodes properly based on generation options.

... See full list

3 invocations of hook_node_insert()
EntityAPIController::save in sites/all/modules/ulmus/entity/includes/entity.controller.inc
Implements EntityAPIControllerInterface.
field_attach_insert in modules/field/field.attach.inc
Save field data for a new entity.
user_save in modules/user/user.module
Save changes to a user account or add a new user.

File

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

Code

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

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.