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().
| Name | Location | Description |
|---|---|---|
| hook_actions_delete | modules/system/system.api.php | Executes code after an action is deleted. |
| hook_action_info | modules/system/system.api.php | Declares information about actions. |
| hook_action_info_alter | modules/system/system.api.php | Alters the actions declared by another module. |
| hook_admin_paths | modules/system/system.api.php | Define administrative paths. |
| hook_admin_paths_alter | modules/system/system.api.php | Redefine administrative paths defined by other modules. |
| hook_aggregator_fetch | modules/aggregator/aggregator.api.php | Implement this hook to create an alternative fetcher for aggregator module. |
| hook_aggregator_fetch_info | modules/aggregator/aggregator.api.php | Implement this hook to expose the title and a short description of your fetcher. |
| hook_aggregator_parse | modules/aggregator/aggregator.api.php | Implement this hook to create an alternative parser for aggregator module. |
| hook_aggregator_parse_info | modules/aggregator/aggregator.api.php | Implement this hook to expose the title and a short description of your parser. |
| hook_aggregator_process | modules/aggregator/aggregator.api.php | Implement this hook to create a processor for aggregator module. |
| hook_aggregator_process_info | modules/aggregator/aggregator.api.php | Implement this hook to expose the title and a short description of your processor. |
| hook_aggregator_remove | modules/aggregator/aggregator.api.php | Implement this hook to remove stored data if a feed is being deleted or a feed's items are being removed. |
| hook_ajax_render_alter | modules/system/system.api.php | Alter the commands that are sent to the user through the AJAX framework. |
| hook_archiver_info | modules/system/system.api.php | Declare archivers to the system. |
| hook_archiver_info_alter | modules/system/system.api.php | Alter archiver information declared by other modules. |
| hook_block_configure | modules/block/block.api.php | Configuration form for the block. |
| hook_block_info | modules/block/block.api.php | Define all blocks provided by the module. |
| hook_block_info_alter | modules/block/block.api.php | Act on blocks prior to rendering. |
| hook_block_save | modules/block/block.api.php | Save the configuration options. |
| hook_block_view | modules/block/block.api.php | Process the block when enabled in a region in order to view its contents. |
| hook_block_view_alter | modules/block/block.api.php | Perform alterations to the content of a block. |
| hook_block_view_MODULE_DELTA_alter | modules/block/block.api.php | Perform alterations to a specific block. |
| hook_boot | modules/system/system.api.php | Perform setup tasks. See also, hook_init. |
| hook_comment_delete | modules/comment/comment.api.php | The comment is being deleted by the moderator. |
| hook_comment_insert | modules/comment/comment.api.php | The comment is being inserted. |
| hook_comment_load | modules/comment/comment.api.php | Comments are being loaded from the database. |
| hook_comment_presave | modules/comment/comment.api.php | The comment passed validation and is about to be saved. |
| hook_comment_publish | modules/comment/comment.api.php | The comment is being published by the moderator. |
| hook_comment_unpublish | modules/comment/comment.api.php | The comment is being unpublished by the moderator. |
| hook_comment_update | modules/comment/comment.api.php | The comment is being updated. |
| hook_comment_view | modules/comment/comment.api.php | The comment is being viewed. This hook can be used to add additional data to the comment before theming. |
| hook_comment_view_alter | modules/comment/comment.api.php | The comment was built; the module may modify the structured content. |
| hook_countries_alter | modules/system/system.api.php | Alter the default country list. |
| hook_cron | modules/system/system.api.php | Perform periodic actions. |
| hook_cron_queue_info | modules/system/system.api.php | Declare queues holding items that need to be run periodically. |
| hook_cron_queue_info_alter | modules/system/system.api.php | Alter cron queue information before cron runs. |
| hook_css_alter | modules/system/system.api.php | Alter CSS files before they are output on the page. |
| hook_custom_theme | modules/system/system.api.php | Return the machine-readable name of the theme to use for the current page. |
| hook_dashboard_regions | modules/dashboard/dashboard.api.php | Adds regions to the dashboard. |
| hook_dashboard_regions_alter | modules/dashboard/dashboard.api.php | Alter dashboard regions provided by modules. |
| hook_date_formats | modules/system/system.api.php | Defines additional date formats. |
| hook_date_formats_alter | modules/system/system.api.php | Alters date types and formats declared by another module. |
| hook_date_format_types | modules/system/system.api.php | Defines additional date types. |
| hook_delete | modules/node/node.api.php | Respond to node deletion. |
| hook_disable | modules/system/system.api.php | Perform necessary actions before module is disabled. |
| hook_drupal_goto_alter | modules/system/system.api.php | Change the page the user is sent to by drupal_goto(). |
| hook_element_info | modules/system/system.api.php | Allows modules to declare their own Forms API element types and specify their default values. |
| hook_element_info_alter | modules/system/system.api.php | Alter the element type information returned from modules. |
| hook_enable | modules/system/system.api.php | Perform necessary actions after module is enabled. |
| hook_entity_info | modules/system/system.api.php | Inform the base system and the Field API about one or more entity types. |
| hook_entity_info_alter | modules/system/system.api.php | Alter the entity info. |
| hook_entity_insert | modules/system/system.api.php | Act on entities when inserted. |
| hook_entity_load | modules/system/system.api.php | Act on entities when loaded. |
| hook_entity_prepare_view | modules/system/system.api.php | Act on entities as they are being prepared for view. |
| hook_entity_update | modules/system/system.api.php | Act on entities when updated. |
| hook_exit | modules/system/system.api.php | Perform cleanup tasks. |
| hook_file_copy | modules/system/system.api.php | Respond to a file that has been copied. |
| hook_file_delete | modules/system/system.api.php | Respond to a file being deleted. |
| hook_file_download | modules/system/system.api.php | Control access to private file downloads and specify HTTP headers. |
| hook_file_insert | modules/system/system.api.php | Respond to a file being added. |
| hook_file_load | modules/system/system.api.php | Load additional information into file objects. |
| hook_file_mimetype_mapping_alter | modules/system/system.api.php | Alter MIME type mappings used to determine MIME type from a file extension. |
| hook_file_move | modules/system/system.api.php | Respond to a file that has been moved. |
| hook_file_references | modules/system/system.api.php | Report the number of times a file is referenced by a module. |
| hook_file_update | modules/system/system.api.php | Respond to a file being updated. |
| hook_file_url_alter | modules/system/system.api.php | Alter the URL to a file. |
| hook_file_validate | modules/system/system.api.php | Check that files meet a given criteria. |
| hook_filter_format_delete | modules/filter/filter.api.php | Perform actions when a text format has been deleted. |
| hook_filter_format_insert | modules/filter/filter.api.php | Perform actions when a new text format has been created. |
| hook_filter_format_update | modules/filter/filter.api.php | Perform actions when a text format has been updated. |
| hook_filter_info | modules/filter/filter.api.php | Define content filters. |
| hook_filter_info_alter | modules/filter/filter.api.php | Perform alterations on filter definitions. |
| hook_flush_caches | modules/system/system.api.php | Add a list of cache tables to be cleared. |
| hook_form | modules/node/node.api.php | Display a node editing form. |
| hook_forms | modules/system/system.api.php | Map form_ids to form builder functions. |
| hook_form_alter | modules/system/system.api.php | Perform alterations before a form is rendered. |
| hook_form_FORM_ID_alter | modules/system/system.api.php | Provide a form-specific alteration instead of the global hook_form_alter(). |
| hook_help | modules/help/help.api.php | Provide online user help. |
| hook_hook_info | modules/system/system.api.php | Defines one or more hooks that are exposed by a module. |
| hook_html_head_alter | modules/system/system.api.php | Alter XHTML HEAD tags before they are rendered by drupal_get_html_head(). |
| hook_image_default_styles | modules/image/image.api.php | Provide module-based image styles for reuse throughout Drupal. |
| hook_image_effect_info | modules/image/image.api.php | Define information about image effects provided by a module. |
| hook_image_styles_alter | modules/image/image.api.php | Modify any image styles provided by other modules or the user. |
| hook_image_style_delete | modules/image/image.api.php | Respond to image style deletion. |
| hook_image_style_flush | modules/image/image.api.php | Respond to image style flushing. |
| hook_image_style_save | modules/image/image.api.php | Respond to image style updating. |
| hook_image_toolkits | modules/system/system.api.php | Define image toolkits provided by this module. |
| hook_init | modules/system/system.api.php | Perform setup tasks. See also, hook_boot. |
| hook_insert | modules/node/node.api.php | Respond to creation of a new node. |
| hook_install | modules/system/system.api.php | Perform setup tasks when the module is installed. |
| hook_install_tasks | modules/system/system.api.php | Return an array of tasks to be performed by an installation profile. |
| hook_install_tasks_alter | modules/system/system.api.php | Alter the full list of installation tasks. |
| hook_js_alter | modules/system/system.api.php | Perform necessary alterations to the JavaScript before it is presented on the page. |
| hook_language_fallback_candidates_alter | modules/locale/locale.api.php | Perform alterations on the language fallback candidates. |
| hook_language_negotiation_info | modules/locale/locale.api.php | Allow modules to define their own language providers. |
| hook_language_negotiation_info_alter | modules/locale/locale.api.php | Perform alterations on language providers. |
| hook_language_switch_links_alter | modules/locale/locale.api.php | Perform alterations on language switcher links. |
| hook_language_types_info | modules/locale/locale.api.php | Allow modules to define their own language types. |
| hook_language_types_info_alter | modules/locale/locale.api.php | Perform alterations on language types. |
| hook_library | modules/system/system.api.php | Registers JavaScript/CSS libraries associated with a module. |
| hook_library_alter | modules/system/system.api.php | Alters the JavaScript/CSS library registry. |
| hook_load | modules/node/node.api.php | Act on nodes being loaded from the database. |
| hook_locale | modules/locale/locale.api.php | Allows modules to define their own text groups that can be translated. |
| hook_mail | modules/system/system.api.php | Prepare a message based on parameters; called from drupal_mail(). |
| hook_mail_alter | modules/system/system.api.php | Alter an email message created with the drupal_mail() function. |
| hook_menu | modules/menu/menu.api.php | Define menu items and page callbacks. |
| hook_menu_active_handler_alter | modules/system/system.api.php | Alters the router item for the active menu handler. |
| hook_menu_alter | modules/menu/menu.api.php | Alter the data being saved to the {menu_router} table after hook_menu is invoked. |
| hook_menu_contextual_links_alter | modules/menu/menu.api.php | Alter contextual links before they are rendered. |
| hook_menu_delete | modules/menu/menu.api.php | Informs modules that a custom menu was deleted. |
| hook_menu_insert | modules/menu/menu.api.php | Informs modules that a custom menu was created. |
| hook_menu_link_alter | modules/menu/menu.api.php | Alter the data being saved to the {menu_links} table by menu_link_save(). |
| hook_menu_link_delete | modules/menu/menu.api.php | Inform modules that a menu link has been deleted. |
| hook_menu_link_insert | modules/menu/menu.api.php | Inform modules that a menu link has been created. |
| hook_menu_link_update | modules/menu/menu.api.php | Inform modules that a menu link has been updated. |
| hook_menu_local_tasks_alter | modules/menu/menu.api.php | Alter tabs and actions displayed on the page before they are rendered. |
| hook_menu_update | modules/menu/menu.api.php | Informs modules that a custom menu was updated. |
| hook_modules_disabled | modules/system/system.api.php | Perform necessary actions after modules are disabled. |
| hook_modules_enabled | modules/system/system.api.php | Perform necessary actions after modules are enabled. |
| hook_modules_installed | modules/system/system.api.php | Perform necessary actions after modules are installed. |
| hook_modules_uninstalled | modules/system/system.api.php | Perform necessary actions after modules are uninstalled. |
| hook_multilingual_settings_changed | modules/locale/locale.api.php | Allow modules to react to language settings changes. |
| hook_node_access | modules/node/node.api.php | Control access to a node. |
| hook_node_access_records | modules/node/node.api.php | Set permissions for a node to be written to the database. |
| hook_node_access_records_alter | modules/node/node.api.php | Alter permissions for a node before it is written to the database. |
| hook_node_delete | modules/node/node.api.php | Respond to node deletion. |
| hook_node_grants | modules/node/node.api.php | Inform the node access system what permissions the user has. |
| hook_node_grants_alter | modules/node/node.api.php | Alter user access rules when trying to view, edit or delete a node. |
| hook_node_info | modules/node/node.api.php | Define module-provided node types. |
| hook_node_insert | modules/node/node.api.php | Respond to creation of a new node. |
| hook_node_load | modules/node/node.api.php | Act on nodes being loaded from the database. |
| hook_node_operations | modules/node/node.api.php | Add mass node operations. |
| hook_node_prepare | modules/node/node.api.php | Act on a node object about to be shown on the add/edit form. |
| hook_node_prepare_translation | modules/node/node.api.php | Act on a node object being cloned for translation. |
| hook_node_presave | modules/node/node.api.php | Act on a node being inserted or updated. |
| hook_node_revision_delete | modules/node/node.api.php | Respond to deletion of a node revision. |
| hook_node_search_result | modules/node/node.api.php | Act on a node being displayed as a search result. |
| hook_node_type_delete | modules/node/node.api.php | Respond to node type deletion. |
| hook_node_type_insert | modules/node/node.api.php | Respond to node type creation. |
| hook_node_type_update | modules/node/node.api.php | Respond to node type updates. |
| hook_node_update | modules/node/node.api.php | Respond to updates to a node. |
| hook_node_update_index | modules/node/node.api.php | Act on a node being indexed for searching. |
| hook_node_validate | modules/node/node.api.php | Perform node validation before a node is created or updated. |
| hook_node_view | modules/node/node.api.php | Act on a node that is being assembled before rendering. |
| hook_node_view_alter | modules/node/node.api.php | Alter the results of node_view(). |
| hook_openid | modules/openid/openid.api.php | Allow modules to modify the OpenID request parameters. |
| hook_openid_discovery_method_info | modules/openid/openid.api.php | Allow modules to declare OpenID discovery methods. |
| hook_openid_discovery_method_info_alter | modules/openid/openid.api.php | Allow modules to alter discovery methods. |
| hook_openid_normalization_method_info | modules/openid/openid.api.php | Allow modules to declare OpenID normalization methods. |
| hook_openid_normalization_method_info_alter | modules/openid/openid.api.php | Allow modules to alter normalization methods. |
| hook_openid_response | modules/openid/openid.api.php | Allow modules to act upon a successful OpenID login. |
| hook_overlay_child_initialize | modules/overlay/overlay.api.php | Allow modules to act when an overlay child window is initialized. |
| hook_overlay_parent_initialize | modules/overlay/overlay.api.php | Allow modules to act when an overlay parent window is initialized. |
| hook_page_alter | modules/system/system.api.php | Perform alterations before a page is rendered. |
| hook_page_build | modules/system/system.api.php | Add elements to a page before it is rendered. |
| hook_page_delivery_callback_alter | modules/system/system.api.php | Alters the delivery callback used to send the result of the page callback to the browser. |
| hook_path_delete | modules/path/path.api.php | The path has been deleted. |
| hook_path_insert | modules/path/path.api.php | The path has been inserted. |
| hook_path_update | modules/path/path.api.php | The path has been updated. |
| hook_permission | modules/system/system.api.php | Define user permissions. |
| hook_prepare | modules/node/node.api.php | Act on a node object about to be shown on the add/edit form. |
| hook_query_alter | modules/system/system.api.php | Perform alterations to a structured query. |
| hook_query_TAG_alter | modules/system/system.api.php | Perform alterations to a structured query for a given tag. |
| hook_ranking | modules/node/node.api.php | Provide additional methods of scoring for core search results for nodes. |
| hook_rdf_mapping | modules/rdf/rdf.api.php | Allow modules to define RDF mappings for field bundles. |
| hook_rdf_namespaces | modules/rdf/rdf.api.php | Allow modules to define namespaces for RDF mappings. |
| hook_registry_files_alter | modules/system/system.api.php | Perform necessary alterations to the list of files parsed by the registry. |
| hook_requirements | modules/system/system.api.php | Check installation requirements and do status reporting. |
| hook_schema | modules/system/system.api.php | Define the current version of the database schema. |
| hook_schema_alter | modules/system/system.api.php | Perform alterations to existing database schemas. |
| hook_search_access | modules/search/search.api.php | Define access to a custom search routine. |
| hook_search_admin | modules/search/search.api.php | Add elements to the search settings form. |
| hook_search_execute | modules/search/search.api.php | Execute a search for a set of key words. |
| hook_search_info | modules/search/search.api.php | Define a custom search type. |
| hook_search_page | modules/search/search.api.php | Override the rendering of search results. |
| hook_search_preprocess | modules/search/search.api.php | Preprocess text for search. |
| hook_search_reset | modules/search/search.api.php | Take action when the search index is going to be rebuilt. |
| hook_search_status | modules/search/search.api.php | Report the status of indexing. |
| hook_shortcut_default_set | modules/shortcut/shortcut.api.php | Return the name of a default shortcut set for the provided user account. |
| hook_simpletest_alter | modules/simpletest/simpletest.api.php | Alter the list of tests. |
| hook_stream_wrappers | modules/system/system.api.php | Registers PHP stream wrapper implementations associated with a module. |
| hook_stream_wrappers_alter | modules/system/system.api.php | Alters the list of PHP stream wrapper implementations. |
| hook_system_info_alter | modules/system/system.api.php | Alter the information parsed from module and theme .info files |
| hook_system_themes_page_alter | modules/system/system.api.php | Alters theme operation links. |
| hook_taxonomy_term_delete | modules/taxonomy/taxonomy.api.php | Respond to the deletion of taxonomy terms. |
| hook_taxonomy_term_insert | modules/taxonomy/taxonomy.api.php | Act on taxonomy terms when inserted. |
| hook_taxonomy_term_load | modules/taxonomy/taxonomy.api.php | Act on taxonomy terms when loaded. |
| hook_taxonomy_term_update | modules/taxonomy/taxonomy.api.php | Act on taxonomy terms when updated. |
| hook_taxonomy_vocabulary_delete | modules/taxonomy/taxonomy.api.php | Respond to the deletion of taxonomy vocabularies. |
| hook_taxonomy_vocabulary_insert | modules/taxonomy/taxonomy.api.php | Act on taxonomy vocabularies when inserted. |
| hook_taxonomy_vocabulary_load | modules/taxonomy/taxonomy.api.php | Act on taxonomy vocabularies when loaded. |
| hook_taxonomy_vocabulary_update | modules/taxonomy/taxonomy.api.php | Act on taxonomy vocabularies when updated. |
| hook_test_finished | modules/simpletest/simpletest.api.php | An individual test has finished. |
| hook_test_group_finished | modules/simpletest/simpletest.api.php | A test group has finished. |
| hook_test_group_started | modules/simpletest/simpletest.api.php | A test group has started. |
| hook_theme | modules/system/system.api.php | Register a module (or theme's) theme implementations. |
| hook_theme_registry_alter | modules/system/system.api.php | Alter the theme registry information returned from hook_theme(). |
| hook_tokens | modules/system/system.api.php | Provide replacement values for placeholder tokens. |
| hook_token_info | modules/system/system.api.php | Provide metadata about available placeholder tokens and token types. |
| hook_token_info_alter | modules/system/system.api.php | Alter the metadata about available placeholder tokens and token types. |
| hook_translated_menu_link_alter | modules/menu/menu.api.php | Alter a menu link after it's translated, but before it's rendered. |
| hook_trigger_info | modules/trigger/trigger.api.php | Declares triggers (events) for users to assign actions to. |
| hook_uninstall | modules/system/system.api.php | Remove any information that the module sets. |
| hook_update | modules/node/node.api.php | Respond to updates to a node. |
| hook_update_dependencies | modules/system/system.api.php | Return an array of information about module update dependencies. |
| hook_update_index | modules/search/search.api.php | Update the search index for this module. |
| hook_update_last_removed | modules/system/system.api.php | Return a number which is no longer available as hook_update_N(). |
| hook_update_N | modules/system/system.api.php | Perform a single update. |
| hook_update_projects_alter | modules/update/update.api.php | Alter the list of projects before fetching data and comparing versions. |
| hook_update_status_alter | modules/update/update.api.php | Alter the information about available updates for projects. |
| hook_upgrades | sites/all/modules/coder/coder_upgrade/coder_upgrade.api.php | Declare upgrade sets for an API (or set of APIs). |
| hook_url_inbound_alter | modules/system/system.api.php | Alters inbound URL requests. |
| hook_url_outbound_alter | modules/system/system.api.php | Alters outbound URLs. |
| hook_username_alter | modules/system/system.api.php | Alter the username that is displayed for a user. |
| hook_user_cancel | modules/user/user.api.php | Act on user account cancellations. |
| hook_user_cancel_methods_alter | modules/user/user.api.php | Modify account cancellation methods. |
| hook_user_categories | modules/user/user.api.php | Retrieve a list of all user setting/information categories. |
| hook_user_delete | modules/user/user.api.php | Respond to user deletion. |
| hook_user_insert | modules/user/user.api.php | A user account was created. |
| hook_user_load | modules/user/user.api.php | Act on user objects when loaded from the database. |
| hook_user_login | modules/user/user.api.php | The user just logged in. |
| hook_user_logout | modules/user/user.api.php | The user just logged out. |
| hook_user_operations | modules/user/user.api.php | Add mass user operations. |
| hook_user_presave | modules/user/user.api.php | A user account is about to be created or updated. |
| hook_user_role_delete | modules/user/user.api.php | Inform other modules that a user role has been deleted. |
| hook_user_role_insert | modules/user/user.api.php | Inform other modules that a user role has been added. |
| hook_user_role_update | modules/user/user.api.php | Inform other modules that a user role has been updated. |
| hook_user_update | modules/user/user.api.php | A user account was updated. |
| hook_user_view | modules/user/user.api.php | The user's account information is being displayed. |
| hook_user_view_alter | modules/user/user.api.php | The user was built; the module may modify the structured content. |
| hook_validate | modules/node/node.api.php | Perform node validation before a node is created or updated. |
| hook_view | modules/node/node.api.php | Display a node. |
| hook_watchdog | modules/system/system.api.php | Log an event message |
| hook_xmlrpc | modules/system/system.api.php | Register XML-RPC callbacks. |
| hook_xmlrpc_alter | modules/system/system.api.php | Alter the definition of XML-RPC methods before they are called. |
| module_hook | includes/module.inc | Determine whether a module implements a hook. |
| module_hook_info | includes/module.inc | Retrieve a list of what hooks are explicitly declared. |
| module_implements | includes/module.inc | Determine which modules are implementing a hook. |
| module_implements_write_cache | includes/module.inc | Writes the hook implementation cache. |
| module_invoke | includes/module.inc | Invoke a hook in a particular module. |
| module_invoke_all | includes/module.inc | Invoke a hook in all enabled modules that implement it. |