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().

Functions

NameLocationDescription
custom_url_rewrite_inbounddocs-6/hooks/core.phpcustom_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...
custom_url_rewrite_outbounddocs-6/hooks/core.phpcustom_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...
drush_hook_COMMANDcontrib-6/drush/drush.api.phpImplementation of the actual drush command.
drush_hook_COMMAND_validatecontrib-6/drush/drush.api.phpRun before a specific command executes.
drush_hook_post_COMMANDcontrib-6/drush/drush.api.phpRun after a specific command executes. Logging an error stops command execution.
drush_hook_pre_COMMANDcontrib-6/drush/drush.api.phpRun before a specific command executes. Logging an error stops command execution.
hook_accessdocs-6/hooks/node.phpDefine access restrictions.
hook_actions_deletedocs-6/hooks/core.phpExecute code after an action is deleted.
hook_action_infodocs-6/hooks/core.phpDeclare information about one or more Drupal actions.
hook_action_info_alterdocs-6/hooks/core.phpAlter the actions declared by another module.
hook_blockdocs-6/hooks/core.phpDeclare a block or set of blocks.
hook_bootdocs-6/hooks/core.phpPerform setup tasks. See also, hook_init.
hook_commentdocs-6/hooks/core.phpRespond to comment actions.
hook_crondocs-6/hooks/core.phpPerform periodic actions.
hook_ctools_plugin_directorycontrib-6/ctools/ctools.api.phpThis hook is used to inform the CTools plugin system about the location of a directory that should be searched for files containing plugins of a particular type. CTools invokes this same hook for all plugins, using the two passed parameters to...
hook_db_rewrite_sqldocs-6/hooks/core.phpRewrite database queries, usually for access control.
hook_deletedocs-6/hooks/node.phpRespond to node deletion.
hook_disabledocs-6/hooks/install.phpPerform necessary actions before module is disabled.
hook_drush_exitcontrib-6/drush/drush.api.phpTake action after any command is run.
hook_drush_initcontrib-6/drush/drush.api.phpTake action before any command is run. Logging an error stops command execution.
hook_drush_pm_adjust_download_destinationcontrib-6/drush/drush.api.phpAdjust the location that a project should be downloaded to.
hook_drush_pm_post_downloadcontrib-6/drush/drush.api.phpTake action after a project has been downloaded.
hook_ec_transaction_deletecontrib-6/ecommerce/ec_store/ec_store.api.phpAct when deleting transactions from the database.
hook_ec_transaction_insertcontrib-6/ecommerce/ec_store/ec_store.api.phpAct when inserting transactions into the database.
hook_ec_transaction_loadcontrib-6/ecommerce/ec_store/ec_store.api.phpAct on transaction objects when loading them from the database.
hook_ec_transaction_post_savecontrib-6/ecommerce/ec_store/ec_store.api.phpAct after saving transaction into database.
hook_ec_transaction_pre_savecontrib-6/ecommerce/ec_store/ec_store.api.phpAct before saving transaction into database.
hook_ec_transaction_typescontrib-6/ecommerce/ec_store/ec_store.api.phpAllow modules to define custom transaction types.
hook_ec_transaction_updatecontrib-6/ecommerce/ec_store/ec_store.api.phpAct when updating transactions into the database.
hook_elementsdocs-6/hooks/core.phpAllows modules to declare their own Forms API element types and specify their default values.
hook_enabledocs-6/hooks/install.phpPerform necessary actions after module is enabled.
hook_exitdocs-6/hooks/core.phpPerform cleanup tasks.
hook_feature_attributescontrib-6/ecommerce/ec_product/ec_product.features.api.phpProvide added product attributes via a feature
hook_feature_ec_checkout_validate_itemcontrib-6/ecommerce/ec_product/ec_product.features.api.phpCheck that a product can be purchased by the current user.
hook_feature_transaction_deletecontrib-6/ecommerce/ec_product/ec_product.features.api.phpDelete additional data into the system for later loading.
hook_feature_transaction_insertcontrib-6/ecommerce/ec_product/ec_product.features.api.phpInsert additional data into the system for later loading.
hook_feature_transaction_loadcontrib-6/ecommerce/ec_product/ec_product.features.api.phpLoad additional information into the transaction item.
hook_feature_transaction_updatecontrib-6/ecommerce/ec_product/ec_product.features.api.phpUpdate additional data into the system for later loading.
hook_file_downloaddocs-6/hooks/core.phpControl access to private file downloads and specify HTTP headers.
hook_filterdocs-6/hooks/core.phpDefine content filters.
hook_filter_tipsdocs-6/hooks/core.phpProvide tips for using filters.
hook_flush_cachesdocs-6/hooks/core.phpAdd a list of cache tables to be cleared.
hook_footerdocs-6/hooks/core.phpInsert closing HTML.
hook_formdocs-6/hooks/node.phpDisplay a node editing form.
hook_formsdocs-6/hooks/core.phpMap form_ids to builder functions.
hook_form_alterdocs-6/hooks/core.phpPerform alterations before a form is rendered.
hook_form_FORM_ID_alterdocs-6/hooks/core.phpProvide a form-specific alteration instead of the global hook_form_alter().
hook_helpdocs-6/hooks/core.phpProvide online user help.
hook_hook_infodocs-6/hooks/core.phpExpose a list of triggers (events) that users can assign actions to.
hook_imagecache_actionscontrib-6/imagecache/imagecache.api.phpInform ImageCache about actions that can be performed on an image.
hook_imagecache_default_presetscontrib-6/imagecache/imagecache.api.phpProvides default ImageCache presets that can be overridden by site administrators.
hook_initdocs-6/hooks/core.phpPerform setup tasks. See also, hook_boot.
hook_insertdocs-6/hooks/node.phpRespond to node insertion.
hook_installdocs-6/hooks/install.phpInstall the current version of the database schema, and any other setup tasks.
hook_linkdocs-6/hooks/core.phpDefine internal Drupal links.
hook_link_alterdocs-6/hooks/core.phpPerform alterations before links on a node or comment are rendered.
hook_loaddocs-6/hooks/node.phpLoad node-type-specific information.
hook_localedocs-6/hooks/core.phpAllows modules to define their own text groups that can be translated.
hook_maildocs-6/hooks/core.phpPrepare a message based on parameters; called from drupal_mail().
hook_mail_alterdocs-6/hooks/core.phpAlter 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_menudocs-6/hooks/core.phpDefine menu items and page callbacks.
hook_menu_alterdocs-6/hooks/core.phpAlter the data being saved to the {menu_router} table after hook_menu is invoked.
hook_menu_link_alterdocs-6/hooks/core.phpAlter the data being saved to the {menu_links} table by menu_link_save().
hook_nodeapidocs-6/hooks/core.phpAct on nodes defined by other modules.
hook_node_access_recordsdocs-6/hooks/core.phpSet permissions for a node to be written to the database.
hook_node_grantsdocs-6/hooks/core.phpInform the node access system what permissions the user has.
hook_node_infodocs-6/hooks/node.phpDefine module-provided node types.
hook_node_operationsdocs-6/hooks/core.phpAdd mass node operations.
hook_node_typedocs-6/hooks/node.phpAct on node type changes.
hook_permdocs-6/hooks/core.phpDefine user permissions.
hook_pingdocs-6/hooks/core.phpPing another server.
hook_pm_post_updatecontrib-6/drush/drush.api.phpTake action after a project has been updated.
hook_preparedocs-6/hooks/node.phpThis is a hook used by node modules. It is called after load but before the node is shown on the add/edit form.
hook_profile_alterdocs-6/hooks/core.phpAlter profile items before they are rendered.
hook_receipt_infocontrib-6/ecommerce/ec_receipt/ec_receipt.api.phpRegister a payment gateway.
hook_receipt_initcontrib-6/ecommerce/ec_receipt/ec_receipt.api.phpInitialize the selected receipting payment type.
hook_receipt_payment_formcontrib-6/ecommerce/ec_receipt/ec_receipt.api.phpGeneration a form for the collection of the payment
hook_receipt_payment_urlcontrib-6/ecommerce/ec_receipt/ec_receipt.api.phpBuild the url to redirect to a hosted payment page.
hook_receipt_process_paymentcontrib-6/ecommerce/ec_receipt/ec_receipt.api.phpInterface with the payment gateway to collect the payment.
hook_requirementsdocs-6/hooks/install.phpCheck installation requirements and do status reporting.
hook_schemadocs-6/hooks/install.phpDefine the current version of the database schema.
hook_schema_alterdocs-6/hooks/core.phpPerform alterations to existing database schemas.
hook_searchdocs-6/hooks/core.phpDefine a custom search routine.
hook_search_preprocessdocs-6/hooks/core.phpPreprocess text for the search index.
hook_system_info_alterdocs-6/hooks/core.phpAlter the information parsed from module and theme .info files
hook_taxonomydocs-6/hooks/core.phpAct on taxonomy changes.
hook_term_pathdocs-6/hooks/core.phpAllows modules to provide an alternative path for the terms it manages.
hook_themedocs-6/hooks/core.phpRegister a module (or theme's) theme implementations.
hook_theme_registry_alterdocs-6/hooks/core.phpAlter the theme registry information returned from hook_theme().
hook_translated_menu_link_alterdocs-6/hooks/core.phpAlter a menu link after it's translated, but before it's rendered.
hook_translation_link_alterdocs-6/hooks/core.phpPerform alterations on translation links.
hook_uninstalldocs-6/hooks/install.phpRemove any tables or variables that the module sets.
hook_updatedocs-6/hooks/node.phpRespond to node updating.
hook_update_indexdocs-6/hooks/core.phpUpdate Drupal's full-text index for this module.
hook_update_last_removeddocs-6/hooks/install.phpReturn a number which is no longer available as hook_update_N().
hook_update_Ndocs-6/hooks/install.phpPerform a single update.
hook_update_projects_alterdocs-6/hooks/core.phpAlter the list of projects before fetching data and comparing versions.
hook_update_status_alterdocs-6/hooks/core.phpAlter the information about available updates for projects.
hook_userdocs-6/hooks/core.phpAct on user account actions.
hook_user_operationsdocs-6/hooks/core.phpAdd mass user operations.
hook_validatedocs-6/hooks/node.phpVerify a node editing form.
hook_viewdocs-6/hooks/node.phpDisplay a node.
hook_watchdogdocs-6/hooks/core.phpLog an event message
hook_xmlrpcdocs-6/hooks/core.phpRegister XML-RPC callbacks.
module_hookdrupal-6/includes/module.incDetermine whether a module implements a hook.
module_implementsdrupal-6/includes/module.incDetermine which modules are implementing a hook.
module_invokedrupal-6/includes/module.incInvoke a hook in a particular module.
module_invoke_alldrupal-6/includes/module.incInvoke a hook in all enabled modules that implement it.
subscriptions_blog_ui_count_user_subscriptionscontrib-6/subscriptions/subscriptions_blog_ui.moduleImplementation of hook_count_user_subscriptions().
subscriptions_blog_ui_subscriptionscontrib-6/subscriptions/subscriptions_blog_ui.moduleImplementation of hook_subscriptions().
subscriptions_cck_subscriptions_get_mailvarscontrib-6/subscriptions/subscriptions_cck.moduleImplementation of hook_subscriptions_get_mailvars().
subscriptions_cck_subscriptions_tokens_listcontrib-6/subscriptions/subscriptions_cck.moduleImplementation of hook_subscriptions_tokens_list().
subscriptions_content_croncontrib-6/subscriptions/subscriptions_content.moduleImplementation of hook_cron().
subscriptions_content_disablecontrib-6/subscriptions/subscriptions_content.moduleImplementation of hook_disable().
subscriptions_content_form_altercontrib-6/subscriptions/subscriptions_content.moduleImplementation of hook_form_alter().
subscriptions_content_form_comment_form_altercontrib-6/subscriptions/subscriptions_content.moduleImplementation of hook_form_alter().
subscriptions_content_form_mail_edit_trans_altercontrib-6/subscriptions/subscriptions_content.moduleImplementation of hook_form_alter().
subscriptions_content_form_node_admin_nodes_altercontrib-6/subscriptions/subscriptions_content.moduleImplementation of hook_form_alter().
subscriptions_content_form_node_type_form_altercontrib-6/subscriptions/subscriptions_content.moduleImplementation of hook_form_alter().
subscriptions_content_form_subscriptions_settings_form_altercontrib-6/subscriptions/subscriptions_content.moduleImplementation of hook_form_alter().
subscriptions_content_mailkeyscontrib-6/subscriptions/subscriptions_content.moduleImplementation of hook_mailkeys().
subscriptions_content_mail_edit_textcontrib-6/subscriptions/subscriptions_content.moduleImplementation of hook_mail_edit_text().
subscriptions_content_mail_edit_tokens_listcontrib-6/subscriptions/subscriptions_content.moduleImplementation of hook_mail_edit_tokens_list().
subscriptions_content_node_typecontrib-6/subscriptions/subscriptions_content.moduleImplementation of hook_node_type().
subscriptions_content_subscriptionscontrib-6/subscriptions/subscriptions_content.moduleImplementation of hook_subscriptions().
subscriptions_form_user_profile_form_altercontrib-6/subscriptions/subscriptions.moduleImplementation of hook_form_alter() for the user/uid/edit form.
subscriptions_initcontrib-6/subscriptions/subscriptions.moduleImplementation of hook_init().
subscriptions_mail_form_mail_edit_trans_altercontrib-6/subscriptions/subscriptions_mail.moduleImplementation of hook_form_alter().
subscriptions_mail_mailkeyscontrib-6/subscriptions/subscriptions_mail.moduleImplementation of hook_mailkeys().
subscriptions_mail_mail_edit_textcontrib-6/subscriptions/subscriptions_mail.moduleImplementation of hook_mail_edit_text().
subscriptions_mail_mail_edit_tokens_listcontrib-6/subscriptions/subscriptions_mail.moduleImplementation of hook_mail_edit_tokens_list().
subscriptions_mail_subscriptions_mail_textcontrib-6/subscriptions/subscriptions_mail.moduleImplementation of hook_subscriptions_mail_text().
subscriptions_mail_subscriptions_tokens_listcontrib-6/subscriptions/subscriptions_mail.moduleImplementation of hook_subscriptions_tokens_list().
subscriptions_menucontrib-6/subscriptions/subscriptions.moduleImplementation of hook_menu().
subscriptions_permcontrib-6/subscriptions/subscriptions.moduleImplementation of hook_perms().
subscriptions_taxonomy_disablecontrib-6/subscriptions/subscriptions_taxonomy.moduleImplementation of hook_disable().
subscriptions_taxonomy_form_subscriptions_settings_form_altercontrib-6/subscriptions/subscriptions_taxonomy.moduleImplementation of hook_form_alter().
subscriptions_taxonomy_mailkeyscontrib-6/subscriptions/subscriptions_taxonomy.moduleImplementation of hook_mailkeys().
subscriptions_taxonomy_mail_edit_textcontrib-6/subscriptions/subscriptions_taxonomy.moduleImplementation of hook_mail_edit_text().
subscriptions_taxonomy_mail_edit_tokens_listcontrib-6/subscriptions/subscriptions_taxonomy.moduleImplementation of hook_mail_edit_tokens_list().
subscriptions_taxonomy_subscriptionscontrib-6/subscriptions/subscriptions_taxonomy.moduleImplementation of hook_subscriptions().
subscriptions_taxonomy_taxonomycontrib-6/subscriptions/subscriptions_taxonomy.moduleImplementation of hook_taxonomy().
subscriptions_typescontrib-6/subscriptions/subscriptions.moduleHook subscription_types(). Get info about subscription types.
subscriptions_ui_blockcontrib-6/subscriptions/subscriptions_ui.moduleImplementation of hook_block().
subscriptions_ui_content_extra_fieldscontrib-6/subscriptions/subscriptions_ui.moduleImplementation of hook hook_content_extra_fields().
subscriptions_ui_form_subscriptions_settings_form_altercontrib-6/subscriptions/subscriptions_ui.moduleImplementation of hook form_alter().
subscriptions_ui_linkcontrib-6/subscriptions/subscriptions_ui.moduleImplementation of hook_link().
subscriptions_ui_nodeapicontrib-6/subscriptions/subscriptions_ui.moduleImplementation of hook_nodeapi().
subscriptions_ui_node_formcontrib-6/subscriptions/subscriptions_ui.moduleReturns the form definition for the node subform.
subscriptions_usercontrib-6/subscriptions/subscriptions.moduleImplementation of hook_user().
_subscriptions_blog_ui_typescontrib-6/subscriptions/subscriptions_blog_ui.moduleImplementation of hook_types(), subhook of hook_subscriptions().
_subscriptions_content_accesscontrib-6/subscriptions/subscriptions_content.moduleImplementation of hook_access(), subhook of hook_subscriptions().
_subscriptions_content_node_optionscontrib-6/subscriptions/subscriptions_content.moduleImplementation of hook_node_options(), subhook of hook_subscriptions().
_subscriptions_content_typescontrib-6/subscriptions/subscriptions_content.moduleImplementation of hook_types(), subhook of hook_subscriptions().
_subscriptions_mail_form_mail_edit_trans_altercontrib-6/subscriptions/subscriptions_mail.admin.incImplementation of hook_form_alter().
_subscriptions_taxonomy_node_optionscontrib-6/subscriptions/subscriptions_taxonomy.moduleImplementation of hook_node_options(), subhook of hook_subscriptions().
_subscriptions_taxonomy_typescontrib-6/subscriptions/subscriptions_taxonomy.moduleImplementation of hook_types(), subhook of hook_subscriptions().

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options