function module_invoke_all

Invokes a hook in all enabled modules that implement it.

All arguments are passed by value. Use drupal_alter() if you need to pass arguments by reference.


$hook: The name of the hook to invoke.

...: Arguments to pass to the hook.

Return value

An array of return values of the hook implementations. If modules return arrays from their implementations, those are merged into one array recursively. Note: integer keys in arrays will be lost, as the merge is done using array_merge_recursive().

See also


Related topics

149 calls to module_invoke_all()
actions_delete in includes/
Deletes a single action from the database.
actions_list in includes/
Discovers all available actions by invoking hook_action_info().
aggregator_remove in modules/aggregator/aggregator.module
Removes all items from a feed.
ajax_footer in includes/
Performs end-of-Ajax-request tasks.
archiver_get_info in includes/
Retrieves a list of all available archivers.

... See full list

1 string reference to 'module_invoke_all'
watchdog in includes/
Logs a system message.


includes/, line 958


function module_invoke_all($hook) {
    $args = func_get_args();
    // Remove $hook from the arguments.
    $return = array();
    foreach (module_implements($hook) as $module) {
        $function = $module . '_' . $hook;
        if (function_exists($function)) {
            $result = call_user_func_array($function, $args);
            if (isset($result) && is_array($result)) {
                $return = array_merge_recursive($return, $result);
            elseif (isset($result)) {
                $return[] = $result;
    return $return;

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.