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
| Name | Location | Description |
|---|---|---|
| custom_url_rewrite_inbound | hooks/core.php | 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... |
| custom_url_rewrite_outbound | hooks/core.php | 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... |
| EMMODULE_PROVIDER_content_generate | contrib/emfield/hooks/emfield.php | Generate random media for the devel module. |
| EMMODULE_PROVIDER_embedded_link | contrib/emfield/hooks/emfield.php | Returns a link to view the original media at the provider's site. |
| EMMODULE_PROVIDER_emfield_submenu | contrib/emfield/hooks/emfield.php | Returns any menu pages required by this provider. |
| EMMODULE_PROVIDER_emfield_subtheme | contrib/emfield/hooks/emfield.php | Returns any theme functions required for this provider. |
| EMMODULE_PROVIDER_extract | contrib/emfield/hooks/emfield.php | Parse the URL or embed code provided by an editor. |
| EMMODULE_PROVIDER_form | contrib/emfield/hooks/emfield.php | Allow a provider to add its own elements to the content creation form. |
| EMMODULE_PROVIDER_info | contrib/emfield/hooks/emfield.php | Return the information about a specific provider. |
| EMMODULE_PROVIDER_submenu | contrib/emfield/hooks/emfield.php | @TODO Not sure why this is there -- provided for already w/ hook_emfield_submenu. |
| EMMODULE_PROVIDER_subtheme | contrib/emfield/hooks/emfield.php | @TODO Not sure why this is there -- provided for already w/ hook_emfield_subtheme. |
| EMMODULE_PROVIDER_validate | contrib/emfield/hooks/emfield.php | Validate the provider's embedded code. |
| hook_access | hooks/node.php | Define access restrictions. |
| hook_actions_delete | hooks/core.php | Execute code after an action is deleted. |
| hook_action_info | hooks/core.php | Declare information about one or more Drupal actions. |
| hook_action_info_alter | hooks/core.php | Alter the actions declared by another module. |
| hook_add_to_cart | contrib/ubercart/docs/hooks.php | Do extra processing when an item is added to the shopping cart. |
| hook_add_to_cart_data | contrib/ubercart/docs/hooks.php | Add extra information to a cart item's "data" array. |
| hook_block | hooks/core.php | Declare a block or set of blocks. |
| hook_boot | hooks/core.php | Perform setup tasks. See also, hook_init. |
| hook_calculate_tax | contrib/ubercart/docs/hooks.php | Calculate tax line items for an order. |
| hook_cart_display | contrib/ubercart/docs/hooks.php | Control the display of an item in the cart. |
| hook_cart_item | contrib/ubercart/docs/hooks.php | Add extra data about an item in the cart. |
| hook_cart_pane | contrib/ubercart/docs/hooks.php | Register callbacks for a cart pane. |
| hook_checkout_pane | contrib/ubercart/docs/hooks.php | Register callbacks for a checkout pane. |
| hook_comment | hooks/core.php | Respond to comment actions. |
| hook_cron | hooks/core.php | Perform periodic actions. |
| hook_db_rewrite_sql | hooks/core.php | Rewrite database queries, usually for access control. |
| hook_delete | hooks/node.php | Respond to node deletion. |
| hook_disable | hooks/install.php | Perform necessary actions before module is disabled. |
| hook_download_authorize | contrib/ubercart/docs/hooks.php | Give clearance to a user to download a file. |
| hook_elements | hooks/core.php | Allows modules to declare their own Forms API element types and specify their default values. |
| hook_emfield_data_alter | contrib/emfield/hooks/emfield.php | Alter the data array of a media item before it is stored in the database. |
| hook_emfield_field_columns_extra | contrib/emfield/hooks/emfield.php | Generally 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_providers | contrib/emfield/hooks/emfield.php | Build a list of provider files that serve the invoking module. |
| hook_emfield_widget_extra | contrib/emfield/hooks/emfield.php | This passes on the original implementation of CCK's hook_widget. |
| hook_emfield_widget_settings_extra | contrib/emfield/hooks/emfield.php | This passes on the original implementation of CCK's hook_widget_settings. |
| hook_enable | hooks/install.php | Perform necessary actions after module is enabled. |
| hook_exit | hooks/core.php | Perform cleanup tasks. |
| hook_file_action | contrib/ubercart/docs/hooks.php | Perform actions on file products. |
| hook_file_download | hooks/core.php | Control access to private file downloads and specify HTTP headers. |
| hook_file_transfer_alter | contrib/ubercart/docs/hooks.php | Make changes to a file before it is downloaded by the customer. |
| hook_filter | hooks/core.php | Define content filters. |
| hook_filter_tips | hooks/core.php | Provide tips for using filters. |
| hook_flush_caches | hooks/core.php | Add a list of cache tables to be cleared. |
| hook_footer | hooks/core.php | Insert closing HTML. |
| hook_form | hooks/node.php | Display a node editing form. |
| hook_forms | hooks/core.php | Map form_ids to builder functions. |
| hook_form_alter | hooks/core.php | Perform alterations before a form is rendered. |
| hook_form_FORM_ID_alter | hooks/core.php | Provide a form-specific alteration instead of the global hook_form_alter(). |
| hook_gmap | contrib/gmap/gmap.php | Change the way gmap works. |
| hook_help | hooks/core.php | Provide online user help. |
| hook_hook_info | hooks/core.php | Expose a list of triggers (events) that users can assign actions to. See alsohook_action_info(), which allows your module to define actions. |
| hook_imagecache_actions | contrib/imagecache/imagecache.api.php | Inform ImageCache about actions that can be performed on an image. |
| hook_imagecache_default_presets | contrib/imagecache/imagecache.api.php | Provides default ImageCache presets that can be overridden by site administrators. |
| hook_init | hooks/core.php | Perform setup tasks. See also, hook_boot. |
| hook_insert | hooks/node.php | Respond to node insertion. |
| hook_install | hooks/install.php | Install the current version of the database schema, and any other setup tasks. |
| hook_line_item | contrib/ubercart/docs/hooks.php | Used to define line items that are attached to orders. |
| hook_line_item_alter | contrib/ubercart/docs/hooks.php | Alter a line item on an order when the order is loaded. |
| hook_line_item_data_alter | contrib/ubercart/docs/hooks.php | Alter the line item definitions declared in hook_line_item(). |
| hook_link | hooks/core.php | Define internal Drupal links. |
| hook_link_alter | hooks/core.php | Perform 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_load | hooks/node.php | Load node-type-specific information. |
| hook_locale | hooks/core.php | Allows modules to define their own text groups that can be translated. |
| hook_mail | hooks/core.php | Prepare a message based on parameters; called from drupal_mail(). |
| hook_mail_alter | hooks/core.php | 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 | hooks/core.php | Define menu items and page callbacks. |
| hook_menu_alter | hooks/core.php | Alter the data being saved to the {menu_router} table after hook_menu is invoked. |
| hook_menu_link_alter | hooks/core.php | Alter the data being saved to the {menu_links} table by menu_link_save(). |
| hook_nodeapi | hooks/core.php | Act on nodes defined by other modules. |
| hook_node_access_records | hooks/core.php | Set permissions for a node to be written to the database. |
| hook_node_grants | hooks/core.php | Inform the node access system what permissions the user has. |
| hook_node_info | hooks/node.php | Define module-provided node types. |
| hook_node_operations | hooks/core.php | Add mass node operations. |
| hook_node_type | hooks/node.php | Act on node type changes. |
| hook_order | contrib/ubercart/docs/hooks.php | Perform actions on orders. |
| hook_order_actions | contrib/ubercart/docs/hooks.php | Add links to local tasks for orders on the admin's list of orders. |
| hook_order_pane | contrib/ubercart/docs/hooks.php | Register callbacks for an order pane. |
| hook_order_product_alter | contrib/ubercart/docs/hooks.php | Allows modules to alter ordered products when they're loaded with an order. |
| hook_order_state | contrib/ubercart/docs/hooks.php | Register static order states. |
| hook_payment_gateway | contrib/ubercart/docs/hooks.php | Register payment gateway callbacks. See also |
| hook_payment_method | contrib/ubercart/docs/hooks.php | Register callbacks for payment methods. |
| hook_perm | hooks/core.php | Define user permissions. |
| hook_ping | hooks/core.php | Ping another server. |
| hook_prepare | hooks/node.php | 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_product_class | contrib/ubercart/docs/hooks.php | Perform actions on product classes. |
| hook_product_description | contrib/ubercart/docs/hooks.php | Return a structured array representing the given product's description. |
| hook_product_description_alter | contrib/ubercart/docs/hooks.php | Alters the given product description. |
| hook_product_types | contrib/ubercart/docs/hooks.php | List node types which should be considered products. |
| hook_profile_alter | hooks/core.php | Alter profile items before they are rendered. |
| hook_requirements | hooks/install.php | Check installation requirements and do status reporting. |
| hook_schema | hooks/install.php | Define the current version of the database schema. |
| hook_schema_alter | hooks/core.php | Perform alterations to existing database schemas. |
| hook_search | hooks/core.php | Define a custom search routine. |
| hook_search_preprocess | hooks/core.php | Preprocess text for the search index. |
| hook_shipment | contrib/ubercart/docs/hooks.php | Handle additional data for shipments. |
| hook_shipping_method | contrib/ubercart/docs/hooks.php | Define callbacks and service options for shipping methods. |
| hook_shipping_type | contrib/ubercart/docs/hooks.php | Define shipping types for shipping methods. |
| hook_store_status | contrib/ubercart/docs/hooks.php | Add status messages to the "Store administration" page. |
| hook_system_info_alter | hooks/core.php | Alter the information parsed from module and theme .info files |
| hook_tapir_table_alter | contrib/ubercart/docs/hooks.php | Allow modules to alter the TAPIr table after the rows are populated. |
| hook_tapir_table_header_alter | contrib/ubercart/docs/hooks.php | Allow modules to alter TAPIr table headers. |
| hook_taxonomy | hooks/core.php | Act on taxonomy changes. |
| hook_term_path | hooks/core.php | Allows modules to provide an alternative path for the terms it manages. |
| hook_theme | hooks/core.php | Register a module (or theme's) theme implementations. |
| hook_theme_registry_alter | hooks/core.php | Alter the theme registry information returned from hook_theme(). |
| hook_translated_menu_link_alter | hooks/core.php | Alter a menu link after it's translated, but before it's rendered. |
| hook_translation_link_alter | hooks/core.php | Perform alterations on translation links. |
| hook_ucga_display | contrib/ubercart/docs/hooks.php | Used to determine whether or not UC Google Analytics should add e-commerce tracking code to the bottom of the page. |
| hook_ucga_item_alter | contrib/ubercart/docs/hooks.php | Allows modules to alter items before they're added to the UC Google Analytics e-commerce tracking code. |
| hook_ucga_trans_alter | contrib/ubercart/docs/hooks.php | Allows modules to alter transaction info before it's added to the UC Google Analytics e-commerce tracking code. |
| hook_uc_checkout_complete | contrib/ubercart/docs/hooks.php | Take action when checkout is completed. |
| hook_uc_form_alter | contrib/ubercart/docs/hooks.php | Allow modules to modify forms before Drupal invokes hook_form_alter(). |
| hook_uc_message | contrib/ubercart/docs/hooks.php | Convenience function to display large blocks of text in several places. |
| hook_uc_payment_entered | contrib/ubercart/docs/hooks.php | Take action when a payment is entered for an order. |
| hook_uc_price_handler | contrib/ubercart/docs/hooks.php | Use 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_models | contrib/ubercart/docs/hooks.php | Notify core of any SKUs your module adds to a given node. |
| hook_uc_stock_adjusted | contrib/ubercart/docs/hooks.php | Allow modules to take action when a stock level is changed. |
| hook_uninstall | hooks/install.php | Remove any tables or variables that the module sets. |
| hook_update | hooks/node.php | Respond to node updating. |
| hook_update_cart_item | contrib/ubercart/docs/hooks.php | Handle requests to update a cart item. |
| hook_update_index | hooks/core.php | Update Drupal's full-text index for this module. |
| hook_update_last_removed | hooks/install.php | Return a number which is no longer available as hook_update_N(). |
| hook_update_N | hooks/install.php | Perform a single update. |
| hook_update_projects_alter | hooks/core.php | Alter the list of projects before fetching data and comparing versions. |
| hook_update_status_alter | hooks/core.php | Alter the information about available updates for projects. |
| hook_user | hooks/core.php | Act on user account actions. |
| hook_user_operations | hooks/core.php | Add mass user operations. |
| hook_validate | hooks/node.php | Verify a node editing form. |
| hook_view | hooks/node.php | Display a node. |
| hook_watchdog | hooks/core.php | Log an event message |
| hook_xmlrpc | hooks/core.php | Register XML-RPC callbacks. |
| module_hook | core/includes/module.inc | Determine whether a module implements a hook. |
| module_implements | core/includes/module.inc | Determine which modules are implementing a hook. |
| module_invoke | core/includes/module.inc | Invoke a hook in a particular module. |
| module_invoke_all | core/includes/module.inc | Invoke a hook in all enabled modules that implement it. |


