Can't use it in a custom module

Created on 16 November 2023, about 1 year ago

Problem/Motivation

I'm writing a custom module on Drupal 10 that needs your new hooks but I can't make it work.
My module's name is "custom_trigger_newsletter" and I added the dependency on custom_trigger_newsletter.info.yml:

name: 'Custom Trigger Newsletter'
type: module
description: 'custom module'
package: Custom
core_version_requirement: ^8 || ^9 || ^10
dependencies:
  - hook_post_action:hook_post_action

In my custom_trigger_newsletter.module file I added this function:

function custom_trigger_newsletter_entity_postinsert(EntityInterface $entity, $op) {
	\Drupal::messenger()->addMessage("action: $op - Entity: $entity->getType()");
}

Nothing happens, I followed your example module (that works correctly) but in my module, even after clearing caches aflter every change, nothing happens.

Can you help me please?

💬 Support request
Status

Active

Version

1.2

Component

Documentation

Created by

🇮🇹Italy smurfxx

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @smurfxx
  • 🇧🇪Belgium dieterholvoet Brussels

    My guess is that adding messages doesn't work anymore at that point, because the post action hooks are executed in a shutdown function, at which point the page is already rendered.

Production build 0.71.5 2024