Allow modules to dynamically implement hooks.

Created on 14 January 2012, about 13 years ago
Updated 10 February 2025, about 1 month ago

As a module developer I would like a way to dynamically implement hooks. What I mean by that is that I could implement just one or two hooks which would return the hook names and handle implementations of whatever hooks my module was configured to react to.

The basic need for it is to simply to make my module aware of certain user-configured events, much like rules invokes a 'rule event'. In fact this would allow something like the rules module to attach to user nominated hook invocation events without any special code by a developer.

I've run into this problem a couple times where I wanted to create a lot of flexibility and have the site perform some task based on the firing of any of the wide variety of hooks invoked by contrib modules. I tried to fudge it with hook_hook_info but it's just not flexible enough.

Plus not to mention a lot of times I have a Rules module invocation it is coupled with a module_invoke or something anyway:

<?php
        if (module_exists('rules')) {
          rules_invoke_event('login_one_time_used', $user);
        }

        module_invoke_all('login_one_time_used', $user);
?>

Which leads me to wonder why rules can't just attach itself to some hook the site administrator wants, but it isn't possible/reasonable to do that at the moment.

To sweeten the deal, modules defining hooks could provide a display string to explain the hook, but that's another story.

Feature request
Status

Closed: won't fix

Component

Idea

Created by

🇦🇺Australia danielb

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024