drupal_alter() ignores more complex function names when the hook is called I have a module named wlm that calls drupal_alter() as follows.

drupal_alter('abc', $ref, $arg1, $arg2);


This works perfectly for a function like the following.

function wlm_abc_alter(&amp;$ref, $arg1, $arg2) { };


However, it breaks/does nothing if the function is similar to the following one.

function wlm_this_is_some_extra_detritus_abc_alter(&amp;$ref, $arg1, $arg2) { };


I want to be able to call this alter function several times within my wlm module, but because the naming convention seems to be limited to module_hook_alter() I can only use it once, which is less than desirable. Is this an intentional design pattern; or is it a mistake; or am I just missing something obvious?

Is it possible to do something like the following, where $my_func_name is delivered dynamically?

drupal_alter($my_func_name . '_abc', $ref, $arg1, $arg2);
It's intentional - a module should only be able to implement a single hook once, and the naming convention requires that the function be called modulename_hookname_alter(). Drupal isn't ignoring your more-verbose function name, but since it doesn't match the name of the hook, it's never going to call it.

You can create other hooks though, based on whatever makes sense to your use case. For example if your module had a bunch of contexts you might create hook_abc_CONTEXT_alter(), and invoke it like so

foreach (mymodule_contexts() as $context_name) {
  $hook_name = 'abc_' . $context_name;
  drupal_alter($hook_name, $ref, $arg1, $arg2);
}


But I think that's as close as Drupal core will let you get to the pattern you're trying to implement.