Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3965768
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T03:30:33+00:00 2026-05-20T03:30:33+00:00

This is a followup to another question I asked abou creating your own hooks.

  • 0

This is a followup to another question I asked abou creating your own hooks.

In the answer and comments, two functions were mentioned

module_invoke_all(...)
drupal_alter(...)

The function module_invoke_all appears to be used to invoke a hook for any module that implements it.

The function drupal_alter appears to invoke a hook for any module that implements it and passes around a persistant data structure between all the hook functions.

Digging through the code, I also found

module_invoke(...)

which appears to let you invoke a specific hook in a specific module.

So, my question is really two questions. First, is my understanding of the above items correct. Second, are there any other core Drupal functions that can be used to invoke hooks implemented in a module?

My end goal is a better understanding of how the pieces of Drupal’s architecture come together to form Drupal, the application, as most people use it. I’m starting with trying to understand the module system in isolation. Any corrections to glaring misconceptions are appreciated

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T03:30:34+00:00Added an answer on May 20, 2026 at 3:30 am

    First question: Yes.

    Second question: Apart from using these functions, you can also call module_implements() directly and call them manually. Example use case is when you want to pass arguments by reference but don’t want an hook_something_alter() naming scheme that drupal_alter() forces you into.

    module_implements() returns an array of modules that implemented the given hook. In Drupal 6 this is simply a loop over all modules and then checking if the function $module . ‘_’ . $hook exists.

    In Drupal 7, it is for example possible to define that your hook_yourmodule_something can be in a anothermodule.yourmodule.inc and Drupal will then automatically look for that file and include it when necessary. See hook_hook_info. Additionally, it is also possible to alter the list of modules that implement a hook, which is rather crazy and should be used with care. See hook_module_implements_alter.

    Because these features make the discovery quite a bit slower than in D6, a cache was added to that. This basically means that whenever you add a hook implementation in D7, you need to clear the cache.

    Example manual implementation:

    <?php
    // Custom hooks should always be prefixed with your module name to avoid naming conflicts.
    $hook_name = 'yourmodule_something';
    // Get a list of all modules implementing the hook.
    foreach (module_implements($hook_name) as $module) {
      // Build the actual function name.
      $function = $module . '_' . $hook_name;
      // Call the function. Anything passed in to the function can be by-reference if the
      // hook_implementation defines it so. If you don't want that, you might want to give them
      // only a copy of the data to prevent abuse.
      $function($arg1, $arg2, $arg3, $arg4);
    }
    ?>
    

    If you look at the code of the functions you linked in your question, you can see that they are basically just helper function for the same procedure, so this should also help to improve the general understanding of hook calling.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a follow-up to another question I asked earlier today. I am creating
This is a followup to another question I asked earlier ( Earlier redirect question
This is a followup question to another question I asked earlier. I thought I
This is a followup/post question to another question; as I have discovered a solution
This is a follow up of another question I asked last night. My problem
This is a followup to the question I asked here: Class Hierarchy - Data
This is a follow up to another question of mine. The solution I found
THis is a followup to my previous question Font-dependent control positioning. It's an attempt
This is a followup question of How to encode characters from Oracle to Xml?
This is a followup to this question . I seem to be stuck on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.