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 call 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 is 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

Namesort iconLocationDescription
custom_url_rewrite_inbounddocs/docs/developer/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/docs/developer/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...
hook_accessdocs/docs/developer/hooks/node.phpDefine access restrictions.
hook_actions_deletedocs/docs/developer/hooks/core.phpExecute code after an action is deleted.
hook_action_infodocs/docs/developer/hooks/core.phpDeclare information about one or more Drupal actions.
hook_action_info_alterdocs/docs/developer/hooks/core.phpAlter the actions declared by another module.
hook_add_to_cartubercart/docs/hooks.phpDo extra processing when an item is added to the shopping cart.
hook_add_to_cart_dataubercart/docs/hooks.phpAdd extra information to a cart item's "data" array.
hook_blockdocs/docs/developer/hooks/core.phpDeclare a block or set of blocks.
hook_bootdocs/docs/developer/hooks/core.phpPerform setup tasks. See also, hook_init.
hook_calculate_taxubercart/docs/hooks.phpCalculate tax line items for an order.
hook_cart_displayubercart/docs/hooks.phpControl the display of an item in the cart.
hook_cart_itemubercart/docs/hooks.phpAdd extra data about an item in the cart.
hook_cart_paneubercart/docs/hooks.phpRegister callbacks for a cart pane.
hook_checkout_paneubercart/docs/hooks.phpRegister callbacks for a checkout pane.
hook_commentdocs/docs/developer/hooks/core.phpAct on comments.
hook_crondocs/docs/developer/hooks/core.phpPerform periodic actions.
hook_db_rewrite_sqldocs/docs/developer/hooks/core.phpRewrite database queries, usually for access control.
hook_deletedocs/docs/developer/hooks/node.phpRespond to node deletion.
hook_disabledocs/docs/developer/hooks/install.phpPerform necessary actions before module is disabled.
hook_download_authorizeubercart/docs/hooks.phpGive clearance to a user to download a file.
hook_elementsdocs/docs/developer/hooks/core.phpAllows modules to declare their own Forms API element types and specify their default values.
hook_enabledocs/docs/developer/hooks/install.phpPerform necessary actions after module is enabled.
hook_exitdocs/docs/developer/hooks/core.phpPerform cleanup tasks.
hook_file_actionubercart/docs/hooks.phpPerform actions on file products.
hook_file_downloaddocs/docs/developer/hooks/core.phpControl access to private file downloads and specify HTTP headers.
hook_file_transfer_alterubercart/docs/hooks.phpMake changes to a file before it is downloaded by the customer.
hook_filterdocs/docs/developer/hooks/core.phpDefine content filters.
hook_filter_tipsdocs/docs/developer/hooks/core.phpProvide tips for using filters.
hook_flush_cachesdocs/docs/developer/hooks/core.phpAdd a list of cache tables to be cleared.
hook_footerdocs/docs/developer/hooks/core.phpInsert closing HTML.
hook_formdocs/docs/developer/hooks/node.phpDisplay a node editing form.
hook_formsdocs/docs/developer/hooks/core.phpMap form_ids to builder functions.
hook_form_alterdocs/docs/developer/hooks/core.phpPerform alterations before a form is rendered.
hook_form_FORM_ID_alterdocs/docs/developer/hooks/core.phpProvide a form-specific alteration instead of the global hook_form_alter().
hook_helpdocs/docs/developer/hooks/core.phpProvide online user help.
hook_hook_infodocs/docs/developer/hooks/core.phpExpose a list of triggers (events) that your module is allowing users to assign actions to.
hook_initdocs/docs/developer/hooks/core.phpPerform setup tasks. See also, hook_boot.
hook_insertdocs/docs/developer/hooks/node.phpRespond to node insertion.
hook_installdocs/docs/developer/hooks/install.phpInstall the current version of the database schema, and any other setup tasks.
hook_line_itemubercart/docs/hooks.phpUsed to define line items that are attached to orders.
hook_line_item_alterubercart/docs/hooks.phpAlter a line item on an order when the order is loaded.
hook_line_item_data_alterubercart/docs/hooks.phpAlter the line item definitions declared in hook_line_item().
hook_linkdocs/docs/developer/hooks/core.phpDefine internal Drupal links.
hook_link_alterdocs/docs/developer/hooks/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_loaddocs/docs/developer/hooks/node.phpLoad node-type-specific information.
hook_localedocs/docs/developer/hooks/core.phpAllows modules to define their own text groups that can be translated.
hook_maildocs/docs/developer/hooks/core.phpPrepare a message based on parameters. @see drupal_mail for more.
hook_mail_alterdocs/docs/developer/hooks/core.phpAlter any aspect of the emails sent by Drupal. You can use this hook to add a common site footer to all outgoing emails; add extra header fields and/or modify the mails sent out in any way. HTML-izing the outgoing mails is one possibility. See also...
hook_menudocs/docs/developer/hooks/core.phpDefine menu items and page callbacks.
hook_menu_alterdocs/docs/developer/hooks/core.phpAlter the data being saved to the {menu_router} table after hook_menu is invoked.
hook_menu_link_alterdocs/docs/developer/hooks/core.phpAlter the data being saved to the {menu_links} table by menu_link_save().
hook_nodeapidocs/docs/developer/hooks/core.phpAct on nodes defined by other modules.
hook_node_access_recordsdocs/docs/developer/hooks/core.phpSet permissions for a node to be written to the database.
hook_node_grantsdocs/docs/developer/hooks/core.phpInform the node access system what permissions the user has.
hook_node_infodocs/docs/developer/hooks/node.phpDefine module-provided node types.
hook_node_operationsdocs/docs/developer/hooks/core.phpAdd mass node operations.
hook_node_typedocs/docs/developer/hooks/node.phpAct on node type changes.
hook_orderubercart/docs/hooks.phpPerform actions on orders.
hook_order_actionsubercart/docs/hooks.phpAdd links to local tasks for orders on the admin's list of orders.
hook_order_paneubercart/docs/hooks.phpRegister callbacks for an order pane.
hook_order_product_alterubercart/docs/hooks.phpAllows modules to alter ordered products when they're loaded with an order.
hook_order_stateubercart/docs/hooks.phpRegister static order states.
hook_payment_gatewayubercart/docs/hooks.phpRegister payment gateway callbacks. See also@link http://www.ubercart.org/docs/api/hook_payment_gateway @endlink
hook_payment_methodubercart/docs/hooks.phpRegister callbacks for payment methods.
hook_permdocs/docs/developer/hooks/core.phpDefine user permissions.
hook_pingdocs/docs/developer/hooks/core.phpPing another server.
hook_preparedocs/docs/developer/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_product_classubercart/docs/hooks.phpPerform actions on product classes.
hook_product_descriptionubercart/docs/hooks.phpReturn a structured array representing the given product's description.
hook_product_description_alterubercart/docs/hooks.phpAlters the given product description.
hook_product_typesubercart/docs/hooks.phpList node types which should be considered products.
hook_profile_alterdocs/docs/developer/hooks/core.phpPerform alterations profile items before they are rendered. You may omit/add/re-sort/re-categorize, etc.
hook_requirementsdocs/docs/developer/hooks/install.phpCheck installation requirements and do status reporting.
hook_schemadocs/docs/developer/hooks/install.phpDefine the current version of the database schema.
hook_schema_alterdocs/docs/developer/hooks/core.phpPerform alterations to existing database schemas.
hook_searchdocs/docs/developer/hooks/core.phpDefine a custom search routine.
hook_search_preprocessdocs/docs/developer/hooks/core.phpPreprocess text for the search index.
hook_shipmentubercart/docs/hooks.phpHandle additional data for shipments.
hook_shipping_methodubercart/docs/hooks.phpDefine callbacks and service options for shipping methods.
hook_shipping_typeubercart/docs/hooks.phpDefine shipping types for shipping methods.
hook_store_statusubercart/docs/hooks.phpAdd status messages to the "Store administration" page.
hook_system_info_alterdocs/docs/developer/hooks/core.phpAlter the information parsed from module and theme .info files
hook_tapir_table_alterubercart/docs/hooks.phpAllow modules to alter the TAPIr table after the rows are populated.
hook_tapir_table_header_alterubercart/docs/hooks.phpAllow modules to alter TAPIr table headers.
hook_taxonomydocs/docs/developer/hooks/core.phpAct on taxonomy changes.
hook_term_pathdocs/docs/developer/hooks/core.phpAllows modules to provide an alternative path for the terms it manages.
hook_themedocs/docs/developer/hooks/core.phpRegister a module (or theme's) theme implementations.
hook_theme_registry_alterdocs/docs/developer/hooks/core.phpAlter the theme registry information returned from hook_theme().
hook_translated_menu_link_alterdocs/docs/developer/hooks/core.phpAlter a menu link after it's translated, but before it's rendered.
hook_translation_link_alterdocs/docs/developer/hooks/core.phpPerform alterations on translation links.
hook_ucga_displayubercart/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_alterubercart/docs/hooks.phpAllows modules to alter items before they're added to the UC Google Analytics e-commerce tracking code.
hook_ucga_trans_alterubercart/docs/hooks.phpAllows modules to alter transaction info before it's added to the UC Google Analytics e-commerce tracking code.
hook_uc_checkout_completeubercart/docs/hooks.phpTake action when checkout is completed.
hook_uc_form_alterubercart/docs/hooks.phpAllow modules to modify forms before Drupal invokes hook_form_alter().
hook_uc_messageubercart/docs/hooks.phpConvenience function to display large blocks of text in several places.
hook_uc_payment_enteredubercart/docs/hooks.phpTake action when a payment is entered for an order.
hook_uc_price_handlerubercart/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_modelsubercart/docs/hooks.phpNotify core of any SKUs your module adds to a given node.
hook_uc_stock_adjustedubercart/docs/hooks.phpAllow modules to take action when a stock level is changed.
hook_uninstalldocs/docs/developer/hooks/install.phpRemove any tables or variables that the module sets.
hook_updatedocs/docs/developer/hooks/node.phpRespond to node updating.
hook_update_cart_itemubercart/docs/hooks.phpHandle requests to update a cart item.
hook_update_indexdocs/docs/developer/hooks/core.phpUpdate Drupal's full-text index for this module.
hook_update_last_removeddocs/docs/developer/hooks/install.phpReturn a number which is no longer available as hook_update_N().
hook_update_Ndocs/docs/developer/hooks/install.phpPerform a single update.
hook_update_status_alterdocs/docs/developer/hooks/core.phpAlter the information about available updates for projects.
hook_userdocs/docs/developer/hooks/core.phpAct on user account actions.
hook_user_operationsdocs/docs/developer/hooks/core.phpAdd mass user operations.
hook_validatedocs/docs/developer/hooks/node.phpVerify a node editing form.
hook_viewdocs/docs/developer/hooks/node.phpDisplay a node.
hook_watchdogdocs/docs/developer/hooks/core.phpLog an event message
hook_xmlrpcdocs/docs/developer/hooks/core.phpRegister XML-RPC callbacks.
module_hookdrupal/includes/module.incDetermine whether a module implements a hook.
module_implementsdrupal/includes/module.incDetermine which modules are implementing a hook.
module_invokedrupal/includes/module.incInvoke a hook in a particular module.
module_invoke_alldrupal/includes/module.incInvoke a hook in all enabled modules that implement it.