Trigger a module function after a node is saved or updated successfully in the database I have used this function hook_node_insert() , but it does not help me because this hook runs before the node is actually saved in the database. I am indexing nodes to a third party application whenever a node is inserted, updated or deleted. The application sends request to the node URL, but using hook_node_insert(). It's giving me an invalid document location error because the node is not actually inserted yet.

Is there any hook invoked after a node is saved or updated in the database?

I followed this approach, without success.

function  my_module_node_insert($node) {
  if (!$node-&gt;type == 'article' || !$node-&gt;type == 'page') { 
    return;
  }
  my_module_do_index($node);
}
You may be able to use Hook Post Action and then use this hook:

function my_module_node_postinsert($node) {
  if(!$node-&gt;type == 'article' || !$node-&gt;type == 'page' ) 
      return;
  my_module_do_index($node) ; // indexes the node
}


Give it a try and see if it helps!

The project link: https://www.drupal.org/project/hook_post_action