1

I just realized hook_node_presave($node) does not yet have a NODE#ID associated with the new node.

Can anyone tell me if there is a hook in the node creating process where I can access the new nodes' nid?

1

hook_node_insert() is the one you're looking for...

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.

0

Some option by attaching function to submit button on node form.

/**
 * Implements hook_form_NODE_TYPE_node_form_alter()
 * Add some action to submit button
 */
function CUSTOM_MODULE_form_NODE_TYPE_node_form_alter(&$form, &$form_state){
    $form['actions']['submit']['#submit'][] = 'CUSTOM_MODULE_form_NODE_TYPE_node_form_submit';
}
function CUSTOM_MODULE_form_NODE_TYPE_node_form_submit(&$form, &$form_state){
    $node = $form_state['node'];
    // YOU CAN GET NID OR EVERYTHING THRUE $node
}

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.