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

Functions

NameLocationDescription
custom_url_rewrite_inboundhooks/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_outboundhooks/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...
EMMODULE_PROVIDER_content_generatecontrib/emfield/hooks/emfield.phpGenerate random media for the devel module.
EMMODULE_PROVIDER_embedded_linkcontrib/emfield/hooks/emfield.phpReturns a link to view the original media at the provider's site.
EMMODULE_PROVIDER_emfield_submenucontrib/emfield/hooks/emfield.phpReturns any menu pages required by this provider.
EMMODULE_PROVIDER_emfield_subthemecontrib/emfield/hooks/emfield.phpReturns any theme functions required for this provider.
EMMODULE_PROVIDER_extractcontrib/emfield/hooks/emfield.phpParse the URL or embed code provided by an editor.
EMMODULE_PROVIDER_formcontrib/emfield/hooks/emfield.phpAllow a provider to add its own elements to the content creation form.
EMMODULE_PROVIDER_infocontrib/emfield/hooks/emfield.phpReturn the information about a specific provider.
EMMODULE_PROVIDER_submenucontrib/emfield/hooks/emfield.php@TODO Not sure why this is there -- provided for already w/ hook_emfield_submenu.
EMMODULE_PROVIDER_subthemecontrib/emfield/hooks/emfield.php@TODO Not sure why this is there -- provided for already w/ hook_emfield_subtheme.
EMMODULE_PROVIDER_validatecontrib/emfield/hooks/emfield.phpValidate the provider's embedded code.
hook_accesshooks/node.phpDefine access restrictions.
hook_actions_deletehooks/core.phpExecute code after an action is deleted.
hook_action_infohooks/core.phpDeclare information about one or more Drupal actions.
hook_action_info_alterhooks/core.phpAlter the actions declared by another module.
hook_add_to_cartcontrib/ubercart/docs/hooks.phpDo extra processing when an item is added to the shopping cart.
hook_add_to_cart_datacontrib/ubercart/docs/hooks.phpAdd extra information to a cart item's "data" array.
hook_blockhooks/core.phpDeclare a block or set of blocks.
hook_boothooks/core.phpPerform setup tasks. See also, hook_init.
hook_calculate_taxcontrib/ubercart/docs/hooks.phpCalculate tax line items for an order.
hook_cart_displaycontrib/ubercart/docs/hooks.phpControl the display of an item in the cart.
hook_cart_itemcontrib/ubercart/docs/hooks.phpAdd extra data about an item in the cart.
hook_cart_panecontrib/ubercart/docs/hooks.phpRegister callbacks for a cart pane.
hook_checkout_panecontrib/ubercart/docs/hooks.phpRegister callbacks for a checkout pane.
hook_commenthooks/core.phpRespond to comment actions.
hook_cronhooks/core.phpPerform periodic actions.
hook_db_rewrite_sqlhooks/core.phpRewrite database queries, usually for access control.
hook_deletehooks/node.phpRespond to node deletion.
hook_disablehooks/install.phpPerform necessary actions before module is disabled.
hook_download_authorizecontrib/ubercart/docs/hooks.phpGive clearance to a user to download a file.
hook_elementshooks/core.phpAllows modules to declare their own Forms API element types and specify their default values.
hook_emfield_data_altercontrib/emfield/hooks/emfield.phpAlter the data array of a media item before it is stored in the database.
hook_emfield_field_columns_extracontrib/emfield/hooks/emfield.phpGenerally used for metadata, this will add an array of database column information to be saved when present in the field. Note that this hook is used to return columns to be saved for all Embedded Media Fields, and is currently unused by the core...
hook_emfield_providerscontrib/emfield/hooks/emfield.phpBuild a list of provider files that serve the invoking module.
hook_emfield_widget_extracontrib/emfield/hooks/emfield.phpThis passes on the original implementation of CCK's hook_widget.
hook_emfield_widget_settings_extracontrib/emfield/hooks/emfield.phpThis passes on the original implementation of CCK's hook_widget_settings.
hook_enablehooks/install.phpPerform necessary actions after module is enabled.
hook_exithooks/core.phpPerform cleanup tasks.
hook_file_actioncontrib/ubercart/docs/hooks.phpPerform actions on file products.
hook_file_downloadhooks/core.phpControl access to private file downloads and specify HTTP headers.
hook_file_transfer_altercontrib/ubercart/docs/hooks.phpMake changes to a file before it is downloaded by the customer.
hook_filterhooks/core.phpDefine content filters.
hook_filter_tipshooks/core.phpProvide tips for using filters.
hook_flush_cacheshooks/core.phpAdd a list of cache tables to be cleared.
hook_footerhooks/core.phpInsert closing HTML.
hook_formhooks/node.phpDisplay a node editing form.
hook_formshooks/core.phpMap form_ids to builder functions.
hook_form_alterhooks/core.phpPerform alterations before a form is rendered.
hook_form_FORM_ID_alterhooks/core.phpProvide a form-specific alteration instead of the global hook_form_alter().
hook_gmapcontrib/gmap/gmap.phpChange the way gmap works.
hook_helphooks/core.phpProvide online user help.
hook_hook_infohooks/core.phpExpose a list of triggers (events) that users can assign actions to. See alsohook_action_info(), which allows your module to define actions.
hook_imagecache_actionscontrib/imagecache/imagecache.api.phpInform ImageCache about actions that can be performed on an image.
hook_imagecache_default_presetscontrib/imagecache/imagecache.api.phpProvides default ImageCache presets that can be overridden by site administrators.
hook_inithooks/core.phpPerform setup tasks. See also, hook_boot.
hook_inserthooks/node.phpRespond to node insertion.
hook_installhooks/install.phpInstall the current version of the database schema, and any other setup tasks.
hook_line_itemcontrib/ubercart/docs/hooks.phpUsed to define line items that are attached to orders.
hook_line_item_altercontrib/ubercart/docs/hooks.phpAlter a line item on an order when the order is loaded.
hook_line_item_data_altercontrib/ubercart/docs/hooks.phpAlter the line item definitions declared in hook_line_item().
hook_linkhooks/core.phpDefine internal Drupal links.
hook_link_alterhooks/core.phpPerform alterations before links on a node are rendered. One popular use of this hook is to modify/remove links from other modules. If you want to add a link to the links section of a node, use hook_link instead.
hook_loadhooks/node.phpLoad node-type-specific information.
hook_localehooks/core.phpAllows modules to define their own text groups that can be translated.
hook_mailhooks/core.phpPrepare a message based on parameters; called from drupal_mail().
hook_mail_alterhooks/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_menuhooks/core.phpDefine menu items and page callbacks.
hook_menu_alterhooks/core.phpAlter the data being saved to the {menu_router} table after hook_menu is invoked.
hook_menu_link_alterhooks/core.phpAlter the data being saved to the {menu_links} table by menu_link_save().
hook_nodeapihooks/core.phpAct on nodes defined by other modules.
hook_node_access_recordshooks/core.phpSet permissions for a node to be written to the database.
hook_node_grantshooks/core.phpInform the node access system what permissions the user has.
hook_node_infohooks/node.phpDefine module-provided node types.
hook_node_operationshooks/core.phpAdd mass node operations.
hook_node_typehooks/node.phpAct on node type changes.
hook_ordercontrib/ubercart/docs/hooks.phpPerform actions on orders.
hook_order_actionscontrib/ubercart/docs/hooks.phpAdd links to local tasks for orders on the admin's list of orders.
hook_order_panecontrib/ubercart/docs/hooks.phpRegister callbacks for an order pane.
hook_order_product_altercontrib/ubercart/docs/hooks.phpAllows modules to alter ordered products when they're loaded with an order.
hook_order_statecontrib/ubercart/docs/hooks.phpRegister static order states.
hook_payment_gatewaycontrib/ubercart/docs/hooks.phpRegister payment gateway callbacks. See also
hook_payment_methodcontrib/ubercart/docs/hooks.phpRegister callbacks for payment methods.
hook_permhooks/core.phpDefine user permissions.
hook_pinghooks/core.phpPing another server.
hook_preparehooks/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_product_classcontrib/ubercart/docs/hooks.phpPerform actions on product classes.
hook_product_descriptioncontrib/ubercart/docs/hooks.phpReturn a structured array representing the given product's description.
hook_product_description_altercontrib/ubercart/docs/hooks.phpAlters the given product description.
hook_product_typescontrib/ubercart/docs/hooks.phpList node types which should be considered products.
hook_profile_alterhooks/core.phpAlter profile items before they are rendered.
hook_requirementshooks/install.phpCheck installation requirements and do status reporting.
hook_schemahooks/install.phpDefine the current version of the database schema.
hook_schema_alterhooks/core.phpPerform alterations to existing database schemas.
hook_searchhooks/core.phpDefine a custom search routine.
hook_search_preprocesshooks/core.phpPreprocess text for the search index.
hook_shipmentcontrib/ubercart/docs/hooks.phpHandle additional data for shipments.
hook_shipping_methodcontrib/ubercart/docs/hooks.phpDefine callbacks and service options for shipping methods.
hook_shipping_typecontrib/ubercart/docs/hooks.phpDefine shipping types for shipping methods.
hook_store_statuscontrib/ubercart/docs/hooks.phpAdd status messages to the "Store administration" page.
hook_system_info_alterhooks/core.phpAlter the information parsed from module and theme .info files
hook_tapir_table_altercontrib/ubercart/docs/hooks.phpAllow modules to alter the TAPIr table after the rows are populated.
hook_tapir_table_header_altercontrib/ubercart/docs/hooks.phpAllow modules to alter TAPIr table headers.
hook_taxonomyhooks/core.phpAct on taxonomy changes.
hook_term_pathhooks/core.phpAllows modules to provide an alternative path for the terms it manages.
hook_themehooks/core.phpRegister a module (or theme's) theme implementations.
hook_theme_registry_alterhooks/core.phpAlter the theme registry information returned from hook_theme().
hook_translated_menu_link_alterhooks/core.phpAlter a menu link after it's translated, but before it's rendered.
hook_translation_link_alterhooks/core.phpPerform alterations on translation links.
hook_ucga_displaycontrib/ubercart/docs/hooks.phpUsed to determine whether or not UC Google Analytics should add e-commerce tracking code to the bottom of the page.
hook_ucga_item_altercontrib/ubercart/docs/hooks.phpAllows modules to alter items before they're added to the UC Google Analytics e-commerce tracking code.
hook_ucga_trans_altercontrib/ubercart/docs/hooks.phpAllows modules to alter transaction info before it's added to the UC Google Analytics e-commerce tracking code.
hook_uc_checkout_completecontrib/ubercart/docs/hooks.phpTake action when checkout is completed.
hook_uc_form_altercontrib/ubercart/docs/hooks.phpAllow modules to modify forms before Drupal invokes hook_form_alter().
hook_uc_messagecontrib/ubercart/docs/hooks.phpConvenience function to display large blocks of text in several places.
hook_uc_payment_enteredcontrib/ubercart/docs/hooks.phpTake action when a payment is entered for an order.
hook_uc_price_handlercontrib/ubercart/docs/hooks.phpUse this hook to define price handlers for your module. You may define one price alterer and one price formatter. You may also define options that are merged into the options array in order of each price alterer's weight.
hook_uc_product_modelscontrib/ubercart/docs/hooks.phpNotify core of any SKUs your module adds to a given node.
hook_uc_stock_adjustedcontrib/ubercart/docs/hooks.phpAllow modules to take action when a stock level is changed.
hook_uninstallhooks/install.phpRemove any tables or variables that the module sets.
hook_updatehooks/node.phpRespond to node updating.
hook_update_cart_itemcontrib/ubercart/docs/hooks.phpHandle requests to update a cart item.
hook_update_indexhooks/core.phpUpdate Drupal's full-text index for this module.
hook_update_last_removedhooks/install.phpReturn a number which is no longer available as hook_update_N().
hook_update_Nhooks/install.phpPerform a single update.
hook_update_projects_alterhooks/core.phpAlter the list of projects before fetching data and comparing versions.
hook_update_status_alterhooks/core.phpAlter the information about available updates for projects.
hook_userhooks/core.phpAct on user account actions.
hook_user_operationshooks/core.phpAdd mass user operations.
hook_validatehooks/node.phpVerify a node editing form.
hook_viewhooks/node.phpDisplay a node.
hook_watchdoghooks/core.phpLog an event message
hook_xmlrpchooks/core.phpRegister XML-RPC callbacks.
module_hookcore/includes/module.incDetermine whether a module implements a hook.
module_implementscore/includes/module.incDetermine which modules are implementing a hook.
module_invokecore/includes/module.incInvoke a hook in a particular module.
module_invoke_allcore/includes/module.incInvoke a hook in all enabled modules that implement it.