Calling all Drupal developers!
Help us get this on the first page of Digg. DIGG NOW!
Help us get this on the first page of Digg. DIGG NOW!
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().
| Name | Location | Description |
|---|---|---|
| custom_url_rewrite | documentation/hooks/core.php | custom_url_rewrite is not a hook, it's a function you can add to settings.php to manage aliases with some code. |
| hook_access | documentation/hooks/node.php | Define access restrictions. |
| hook_add_to_cart | contributions/ubercart/docs/hooks.php | Do extra processing when an item is added to the shopping cart. |
| hook_add_to_cart_data | contributions/ubercart/docs/hooks.php | Add extra information to a cart item's "data" array. |
| hook_auth | documentation/hooks/authentication.php | Verify authentication of a user. |
| hook_block | documentation/hooks/core.php | Declare a block or set of blocks. |
| hook_calculate_tax | contributions/ubercart/docs/hooks.php | Calculate tax line items for an order. |
| hook_cart_display | contributions/ubercart/docs/hooks.php | Control the display of an item in the cart. |
| hook_cart_item | contributions/ubercart/docs/hooks.php | Add extra data about an item in the cart. |
| hook_cart_pane | contributions/ubercart/docs/hooks.php | Register callbacks for a cart pane. |
| hook_checkout_pane | contributions/ubercart/docs/hooks.php | Register callbacks for a checkout pane. |
| hook_comment | documentation/hooks/core.php | Act on comments. |
| hook_cron | documentation/hooks/core.php | Perform periodic actions. |
| hook_db_rewrite_sql | documentation/hooks/core.php | Add JOIN and WHERE statements to queries and decide whether the primary_field shall be made DISTINCT. For node objects, primary field is always called nid. For taxonomy terms, it is tid and for vocabularies it is vid. For comments, it is cid. Primary... |
| hook_delete | documentation/hooks/node.php | Respond to node deletion. |
| hook_disable | documentation/hooks/install.php | Perform necessary actions before module is disabled. |
| hook_download_authorize | contributions/ubercart/docs/hooks.php | Give clearance to a user to download a file. |
| hook_elements | documentation/hooks/core.php | Allows modules to declare their own form element types and specify their default values. |
| hook_enable | documentation/hooks/install.php | Perform necessary actions after module is enabled. |
| hook_exit | documentation/hooks/core.php | Perform cleanup tasks. |
| hook_field | contributions/cck/field.php | Define the behavior of a field type. |
| hook_field_formatter | contributions/cck/field.php | Prepare an individual item for viewing in a browser. |
| hook_field_formatter_info | contributions/cck/field.php | Declare information about a formatter. |
| hook_field_info | contributions/cck/field.php | Declare information about a field type. |
| hook_field_settings | contributions/cck/field.php | Handle the parameters for a field. |
| hook_file_action | contributions/ubercart/docs/hooks.php | Perform actions on file products. |
| hook_file_download | documentation/hooks/core.php | Allow file downloads. |
| hook_file_transfer_alter | contributions/ubercart/docs/hooks.php | Make changes to a file before it is downloaded by the customer. |
| hook_filter | documentation/hooks/core.php | Define content filters. |
| hook_filter_tips | documentation/hooks/core.php | Provide tips for using filters. |
| hook_footer | documentation/hooks/core.php | Insert closing HTML. |
| hook_form | documentation/hooks/node.php | Display a node editing form. |
| hook_forms | documentation/hooks/core.php | Map form_ids to builder functions. |
| hook_form_alter | documentation/hooks/core.php | Perform alterations before a form is rendered. |
| hook_gmap | contributions/gmap/gmap.php | Change the way gmap works. |
| hook_help | documentation/hooks/core.php | Provide online user help. |
| hook_info | documentation/hooks/authentication.php | Declare authentication scheme information. |
| hook_init | documentation/hooks/core.php | Perform setup tasks. |
| hook_insert | documentation/hooks/node.php | Respond to node insertion. |
| hook_install | documentation/hooks/install.php | Install the current version of the database schema. |
| hook_line_item | contributions/ubercart/docs/hooks.php | Used to define line items that are attached to orders. |
| hook_link | documentation/hooks/core.php | Define internal Drupal links. |
| hook_link_alter | documentation/hooks/core.php | Perform alterations before links on a node are rendered. One popular use of this hook is to add/delete links from other modules. |
| hook_load | documentation/hooks/node.php | Load node-type-specific information. |
| hook_mail_alter | documentation/hooks/core.php | Alter 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_menu | documentation/hooks/core.php | Define menu items and page callbacks. |
| hook_nodeapi | documentation/hooks/core.php | Act on nodes defined by other modules. |
| hook_node_access_records | documentation/hooks/core.php | Set permissions for a node to be written to the database. |
| hook_node_grants | documentation/hooks/core.php | Inform the node access system what permissions the user has. |
| hook_node_info | documentation/hooks/node.php | Define module-provided node types. |
| hook_node_operations | documentation/hooks/core.php | Add mass node operations. |
| hook_node_type | documentation/hooks/node.php | Act on node type changes. |
| hook_order | contributions/ubercart/docs/hooks.php | Perform actions on orders. |
| hook_order_actions | contributions/ubercart/docs/hooks.php | Add links to local tasks for orders on the admin's list of orders. |
| hook_order_pane | contributions/ubercart/docs/hooks.php | Register callbacks for an order pane. |
| hook_payment_gateway | contributions/ubercart/docs/hooks.php | Register payment gateway callbacks. See also@link http://www.ubercart.org/docs/api/hook_payment_gateway @endlink |
| hook_payment_method | contributions/ubercart/docs/hooks.php | Register callbacks for payment methods. |
| hook_perm | documentation/hooks/core.php | Define user permissions. |
| hook_ping | documentation/hooks/core.php | Ping another server. |
| hook_prepare | documentation/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 | contributions/ubercart/docs/hooks.php | Perform actions on product classes. |
| hook_product_types | contributions/ubercart/docs/hooks.php | List node types which should be considered products. |
| hook_profile_alter | documentation/hooks/core.php | Perform alterations profile items before they are rendered. You may omit/add/re-sort/re-categorize, etc. |
| hook_requirements | documentation/hooks/install.php | Check installation requirements that need to be satisfied. |
| hook_search | documentation/hooks/core.php | Define a custom search routine. |
| hook_search_preprocess | documentation/hooks/core.php | Preprocess text for the search index. |
| hook_shipment | contributions/ubercart/docs/hooks.php | Handle additional data for shipments. |
| hook_shipping_method | contributions/ubercart/docs/hooks.php | Define callbacks and service options for shipping methods. |
| hook_shipping_type | contributions/ubercart/docs/hooks.php | Define shipping types for shipping methods. |
| hook_store_status | contributions/ubercart/docs/hooks.php | Add status messages to the "Store administration" page. |
| hook_submit | documentation/hooks/node.php | This is a hook used by node modules. It is called after validation has succeeded and before insert/update. It is used to for actions which must happen only if the node is to be saved. Usually, $node is changed in some way and then the actual saving of... |
| hook_taxonomy | documentation/hooks/core.php | Act on taxonomy changes. |
| hook_uc_message | contributions/ubercart/docs/hooks.php | Convenience function to display large blocks of text in several places. |
| hook_uninstall | documentation/hooks/install.php | Remove any tables or variables that the module sets. |
| hook_update | documentation/hooks/node.php | Respond to node updating. |
| hook_update_cart_item | contributions/ubercart/docs/hooks.php | Handle requests to update a cart item. |
| hook_update_index | documentation/hooks/core.php | Update Drupal's full-text index for this module. |
| hook_update_N | documentation/hooks/install.php | Perform a single update. For each patch which requires a database change add a new hook_update_N() which will be called by update.php. |
| hook_user | documentation/hooks/core.php | Act on user account actions. |
| hook_user_operations | documentation/hooks/core.php | Add mass user operations. |
| hook_validate | documentation/hooks/node.php | Verify a node editing form. |
| hook_view | documentation/hooks/node.php | Display a node. |
| hook_widget | contributions/cck/field.php | Define the behavior of a widget. |
| hook_widget_info | contributions/cck/field.php | Declare information about a widget. |
| hook_widget_settings | contributions/cck/field.php | Handle the parameters for a widget. |
| hook_xmlrpc | documentation/hooks/core.php | Register XML-RPC callbacks. |
| hook_xmlsitemap_engines | contributions/xmlsitemap/docs/xmlsitemap.php | Define actions for search engines. |
| hook_xmlsitemap_links | contributions/xmlsitemap/docs/xmlsitemap.php | Define additional links to add to the site map. |
| module_hook | 5/includes/module.inc | Determine whether a module implements a hook. |
| module_implements | 5/includes/module.inc | Determine which modules are implementing a hook. |
| module_invoke | 5/includes/module.inc | Invoke a hook in a particular module. |
| module_invoke_all | 5/includes/module.inc | Invoke a hook in all enabled modules that implement it. |