Drupal is a registered trademark of Dries Buytaert
drupal 11.3.7 Update released for Drupal core (11.3.7)! drupal 11.2.11 Update released for Drupal core (11.2.11)! drupal 10.6.7 Update released for Drupal core (10.6.7)! drupal 10.5.9 Update released for Drupal core (10.5.9)! cms 2.1.1 Update released for Drupal core (2.1.1)! drupal 11.3.6 Update released for Drupal core (11.3.6)! drupal 10.6.6 Update released for Drupal core (10.6.6)! cms 2.1.0 Update released for Drupal core (2.1.0)! bootstrap 8.x-3.40 Minor update available for theme bootstrap (8.x-3.40). menu_link_attributes 8.x-1.7 Minor update available for module menu_link_attributes (8.x-1.7). eca 3.1.1 Minor update available for module eca (3.1.1). layout_paragraphs 2.1.3 Minor update available for module layout_paragraphs (2.1.3). ai 1.3.3 Minor update available for module ai (1.3.3). ai 1.2.14 Minor update available for module ai (1.2.14). node_revision_delete 2.0.3 Minor update available for module node_revision_delete (2.0.3). moderated_content_bulk_publish 2.0.52 Minor update available for module moderated_content_bulk_publish (2.0.52). klaro 3.0.10 Minor update available for module klaro (3.0.10). klaro 3.0.9 Minor update available for module klaro (3.0.9). layout_paragraphs 2.1.2 Minor update available for module layout_paragraphs (2.1.2). geofield_map 11.1.8 Minor update available for module geofield_map (11.1.8).

hook_post_action

5,294 sites Security covered
View on drupal.org

You don't need this module unless you're either a developer or another module you're using depends on it.

Currently Drupal core does not offer any hook to do actions after a node/entity is insered/updated/deleted in the database. So this module introduces several new Drupal hooks to overcome this limitation:

  • hook_entity_postsave
  • hook_entity_postinsert
  • hook_entity_postupdate
  • hook_entity_postdelete
  • hook_node_postsave
  • hook_node_postinsert
  • hook_node_postupdate
  • hook_node_postdelete

Installation

Install and enable the module as usual.

Usage

Please read the hook_post_action.api file.

Also if you want to quickly see it working, you can enable the bundled module hook_post_action_example, add/delete/update some content and visit the logs at /admin/reports/dblog. You'll see log messages for each hook that was fired.

WARNING: The _postsave, _postinsert and _postupdate hooks are also called when the entity/node is deleted, as there is no way to find out whether the entity/node is actually saved/inserted/updated. However, the module does only call the delete hooks when the entity/node is actually deleted from database.

A simple example

<?php
/**
 * Gets called after a node has been deleted from database.
 *
 * @param $node
 *   A node object
 *
 * @see hook_node_postsave()
 * @see hook_node_postinsert()
 * @see hook_node_postupdate()
 * @see hook_node_postdelete()
 */
function hook_post_action_example_node_postdelete($node) {
  watchdog('hook_post_action_test', "The deleted node {$node->type} id is {$node->nid} from " . __FUNCTION__);
}

Activity

Total releases
3
First release
Nov 2025
Latest release
5 months ago
Release cadence
0 days
Stability
67% stable

Release Timeline

Releases

Version Type Release date
8.x-1.3 Stable Nov 11, 2025
2.0.0 Stable Nov 11, 2025
2.0.x-dev Dev Nov 11, 2025