function node_access_example_node_insert in Examples for Developers 7
Implements hook_node_insert().
Insert a new access record when a node is created.
See also
Related topics
1 call to node_access_example_node_insert()
- node_access_example_node_update in node_access_example/
node_access_example.module - Implements hook_node_update().
File
- node_access_example/
node_access_example.module, line 429 - Module file illustrating API-based node access.
Code
function node_access_example_node_insert($node) {
if (isset($node->private)) {
db_insert('node_access_example')
->fields(array(
'nid' => $node->nid,
'private' => (int) $node->private,
))
->execute();
}
drupal_set_message(t('New node @nid was created and private=@private', array(
'@nid' => $node->nid,
'@private' => !empty($node->private) ? 1 : 0,
)));
}