0

I understand I could use hook_nodeapi('insert') in Drupal 6 (Drupal hook fired after node created), but this seems to have changed in Drupal 7. What would the equivalent of that in Drupal 7?

3

The equivalent of hook_nodeapi('insert') in Drupal 7 is hook_node_insert().

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

In Drupal 7, several hooks that previously allowed modules to do a group of related operations, with a $op argument, were split into individual hooks for each operation.

See node.api.php.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.