Hooks
Allow modules to interact with the Drupal core.
Drupal's module system is based on the concept of "hooks". A hook is a PHP function that is named foo_bar(), where "foo" is the name of the module (whose filename is thus foo.module) and "bar" is the name of the hook. Each hook has a defined set of parameters and a specified result type.
To extend Drupal, a module need simply implement a hook. When Drupal wishes to allow intervention from modules, it determines which modules implement a hook and calls that hook in all enabled modules that implement it.
The available hooks to implement are explained here in the Hooks section of the developer documentation. The string "hook" is used as a placeholder for the module name in the hook definitions. For example, if the module file is called example.module, then hook_help() as implemented by that module would be defined as example_help().
File
- drupal-6.x/
includes/ module.inc, line 379 - API for loading and interacting with Drupal modules.
Functions
Name | Location | Description |
---|---|---|
hook_action_info |
documentation-6.x/ |
Declare information about one or more Drupal actions. |
hook_actions_delete |
documentation-6.x/ |
Execute code after an action is deleted. |
hook_action_info_alter |
documentation-6.x/ |
Alter the actions declared by another module. |
hook_block |
documentation-6.x/ |
Declare a block or set of blocks. |
hook_comment |
documentation-6.x/ |
Respond to comment actions. |
hook_cron |
documentation-6.x/ |
Perform periodic actions. |
hook_hook_info |
documentation-6.x/ |
Expose a list of triggers (events) that users can assign actions to. |
hook_menu_alter |
documentation-6.x/ |
Alter the data being saved to the {menu_router} table after hook_menu is invoked. |
hook_menu_link_alter |
documentation-6.x/ |
Alter the data being saved to the {menu_links} table by menu_link_save(). |
hook_translated_menu_link_alter |
documentation-6.x/ |
Alter a menu link after it's translated, but before it's rendered. |
hook_db_rewrite_sql |
documentation-6.x/ |
Rewrite database queries, usually for access control. |
hook_elements |
documentation-6.x/ |
Allows modules to declare their own Forms API element types and specify their default values. |
hook_exit |
documentation-6.x/ |
Perform cleanup tasks. |
hook_file_download |
documentation-6.x/ |
Control access to private file downloads and specify HTTP headers. |
hook_filter |
documentation-6.x/ |
Define content filters. |
hook_filter_tips |
documentation-6.x/ |
Provide tips for using filters. |
hook_footer |
documentation-6.x/ |
Insert closing HTML. |
hook_schema_alter |
documentation-6.x/ |
Performs alterations to existing database schemas. |
hook_form_alter |
documentation-6.x/ |
Perform alterations before a form is rendered. |
hook_form_FORM_ID_alter |
documentation-6.x/ |
Provide a form-specific alteration instead of the global hook_form_alter(). |
hook_forms |
documentation-6.x/ |
Map form_ids to builder functions. |
hook_help |
documentation-6.x/ |
Provide online user help. |
page_cache_fastpath |
documentation-6.x/ |
Outputs a cached page. |
hook_boot |
documentation-6.x/ |
Perform setup tasks. See also, hook_init. |
hook_init |
documentation-6.x/ |
Perform setup tasks. See also, hook_boot. |
hook_link |
documentation-6.x/ |
Define internal Drupal links. |
hook_link_alter |
documentation-6.x/ |
Perform alterations before links on a node or comment are rendered. |
hook_profile_alter |
documentation-6.x/ |
Alter profile items before they are rendered. |
hook_mail_alter |
documentation-6.x/ |
Alter any aspect of email sent by Drupal. You can use this hook to add a common site footer to all outgoing email, add extra header fields, and/or modify the email in any way. HTML-izing the outgoing email is one possibility. See also drupal_mail(). |
hook_menu |
documentation-6.x/ |
Define menu items and page callbacks. |
hook_system_info_alter |
documentation-6.x/ |
Alter the information parsed from module and theme .info files |
hook_update_status_alter |
documentation-6.x/ |
Alter the information about available updates for projects. |
hook_update_projects_alter |
documentation-6.x/ |
Alter the list of projects before fetching data and comparing versions. |
hook_node_grants |
documentation-6.x/ |
Inform the node access system what permissions the user has. |
hook_node_access_records |
documentation-6.x/ |
Set permissions for a node to be written to the database. |
hook_node_operations |
documentation-6.x/ |
Add mass node operations. |
hook_nodeapi |
documentation-6.x/ |
Act on nodes defined by other modules. |
hook_openid |
documentation-6.x/ |
Allow modules to modify the OpenID request parameters. |
hook_perm |
documentation-6.x/ |
Define user permissions. |
hook_ping |
documentation-6.x/ |
Ping another server. |
hook_search |
documentation-6.x/ |
Define a custom search routine. |
hook_search_preprocess |
documentation-6.x/ |
Preprocess text for the search index. |
hook_search_page |
documentation-6.x/ |
Override the rendering of search results. |
hook_taxonomy |
documentation-6.x/ |
Act on taxonomy changes. |
hook_theme |
documentation-6.x/ |
Register a module (or theme's) theme implementations. |
hook_theme_registry_alter |
documentation-6.x/ |
Alter the theme registry information returned from hook_theme(). |
hook_preprocess |
documentation-6.x/ |
Preprocess theme variables for template files. |
hook_preprocess_HOOK |
documentation-6.x/ |
Preprocess theme variables for a specific theme hook. |
hook_update_index |
documentation-6.x/ |
Update Drupal's full-text index for this module. |
hook_user |
documentation-6.x/ |
Act on user account actions. |
hook_user_operations |
documentation-6.x/ |
Add mass user operations. |
hook_xmlrpc |
documentation-6.x/ |
Register XML-RPC callbacks. |
hook_watchdog |
documentation-6.x/ |
Log an event message |
hook_mail |
documentation-6.x/ |
Prepare a message based on parameters; called from drupal_mail(). |
hook_flush_caches |
documentation-6.x/ |
Add a list of cache tables to be cleared. |
hook_term_path |
documentation-6.x/ |
Allows modules to provide an alternative path for the terms it manages. |
hook_locale |
documentation-6.x/ |
Allows modules to define their own text groups that can be translated. |
custom_url_rewrite_outbound |
documentation-6.x/ |
custom_url_rewrite_outbound is not a hook, it's a function you can add to settings.php to alter all links generated by Drupal. This function is called from url(). This function is called very frequently (100+ times per page) so performance… |
custom_url_rewrite_inbound |
documentation-6.x/ |
custom_url_rewrite_inbound is not a hook, it's a function you can add to settings.php to alter incoming requests so they map to a Drupal path. This function is called before modules are loaded and the menu system is initialized and it changes… |
hook_translation_link_alter |
documentation-6.x/ |
Perform alterations on translation links. |
hook_requirements |
documentation-6.x/ |
Check installation requirements and do status reporting. |
hook_schema |
documentation-6.x/ |
Define the current version of the database schema. |
hook_install |
documentation-6.x/ |
Install the current version of the database schema, and any other setup tasks. |
hook_update_N |
documentation-6.x/ |
Perform a single update. |
hook_uninstall |
documentation-6.x/ |
Remove any information that the module sets. |
hook_update_last_removed |
documentation-6.x/ |
Return a number which is no longer available as hook_update_N(). |
hook_enable |
documentation-6.x/ |
Perform necessary actions after module is enabled. |
hook_disable |
documentation-6.x/ |
Perform necessary actions before module is disabled. |
hook_node_info |
documentation-6.x/ |
Define module-provided node types. |
hook_node_type |
documentation-6.x/ |
Act on node type changes. |
hook_access |
documentation-6.x/ |
Define access restrictions. |
hook_delete |
documentation-6.x/ |
Respond to node deletion. |
hook_prepare |
documentation-6.x/ |
This is a hook used by node modules. It is called after load but before the node is shown on the add/edit form. |
hook_form |
documentation-6.x/ |
Display a node editing form. |
hook_insert |
documentation-6.x/ |
Respond to node insertion. |
hook_load |
documentation-6.x/ |
Load node-type-specific information. |
hook_update |
documentation-6.x/ |
Respond to node updating. |
hook_validate |
documentation-6.x/ |
Verify a node editing form. |
hook_view |
documentation-6.x/ |
Display a node. |
module_hook |
drupal-6.x/ |
Determine whether a module implements a hook. |
module_implements |
drupal-6.x/ |
Determine which modules are implementing a hook. |
module_invoke |
drupal-6.x/ |
Invoke a hook in a particular module. |
module_invoke_all |
drupal-6.x/ |
Invoke a hook in all enabled modules that implement it. |