Extension hook registry

From MediaWiki.org
Jump to navigation Jump to search

The Hooks mechanism in MediaWiki is a powerful tool for extension authors to modify the behavior of MediaWiki while minimizing, if not eliminating, the need to hack the codebase. A logical extension of this idea is to place hooks in extensions themselves, in order to allow other developers to further extend those extensions. This page provides a listing and documentation for hooks provided by extension authors.

To document an extension hook:

  1. Create a page named after the hook under your extension, e.g. Extension:MyExtension/MyHook. Note: this naming convention allows defaults and category links in Template:Extension and Template:SeeCustomHook to work properly.
  2. Add a row for your hook in the table below.

Extension hooks by parent extension[edit]

Parent extension Version
Revision Hook Description
Admin Links AdminLinks Allows for adding sections and links to the Special:AdminLinks page.
Approved Revs ApprovedRevsRevisionApproved Called when a page revision is approved.
Approved Revs ApprovedRevsRevisionUnapproved Called when a page revision is unapproved.
Approved Revs ApprovedRevsFileRevisionApproved Called when a file revision is approved.
Approved Revs ApprovedRevsFileRevisionUnapproved Called when a file revision is unapproved.
Cargo 2.0 CargoBeforeStoreData Allows for modifying data values before they are stored in the database
Cargo 0.5 CargoGetFormatClass Allows for specifying custom display format classes
Cargo 2.0 CargoTablesActionLinks Allows for modifying the set of links shown for each table in Special:CargoTables
CentralAuth 1.13 CentralAuthWikiList Get the list of wikis in which CentralAuth is active
ContactPage ContactForm Can be used to manipulate most of the values related to the contact message: the sender, the receiver, the subject and the actual contact message text.
ContactPage r60638 ContactFormBeforeMessage Can be used to add new fields to Special:Contact. Two parameters, $contactForm (Object; instance of EmailContactForm class) and &$form (HTML used to generate the form).
ContactPage ContactFromComplete Takes the same parameters as ContactForm hook does.
Echo BeforeCreateEchoEvent Allows registration of custom Echo events
GoogleNewsSitemap GoogleNewsSitemap::Query Modifies the query used by GoogleNewsSitemap (used for flagged revs support)
LDAP Authentication 1.1c+ SetUsernameAttributeFromLDAP Allows hook function to set the LDAP username from various attributes returned by a query.
MathSearch MathSearchGenerateAnchorString allows for customization of formula Ids that are not set explicitly by the user
MobileFrontend 3b5e3c07f39e EnableMobileModules Allow other extensions to add modules depending on the MobileFrontend mode
NewUserMessage 3.1 CreateNewUserMessage Hook for modules that allows them to override the default new user message.
Nuke 1.27.0 NukeGetNewPages Called after searching for pages to delete; can be used to add and remove pages.
Nuke 1.27.0 NukeDeletePage Allows other extensions to handle the deletion of titles.
Page Forms PageForms::AddRLModules Allows for adding additional ResourceLoader modules to forms
Page Forms PageForms::BeforeFreeTextSubst Allows for modifying the free text field
Page Forms PageForms::CreateFormField Allows for modifying a form field
Page Forms PageForms::CreateTemplateText Called when generating a template via one of the helper pages
Page Forms PageForms::EditFormPreloadText Can be used to set or change the preload text, for new pages
Page Forms PageForms::FormPrinterSetup Called as part of the form setup
Page Forms PageForms::HTMLBeforeForm Can be used to insert additional HTML at the beginning of the form
Page Forms PageForms::PrintRedirectForm Can be used to modify the mini-form that redirects users to the real form
Page Forms PageForms::RenderingEnd Called at the end of the form display
Page Forms PageForms::SetTargetName Can be used to set the "target" page name, based on a passed-in page name
Page Forms PageForms::TemplateFieldStart Called before generating a field in an automatically-generated template page
Page Forms PageForms::TemplateFieldEnd Called after generating a field in an automatically-generated template page
Page Forms PageForms::UserCanEditPage Can be used to set whether a user can edit a page
Page Forms PageForms::WritePageData Can be used to process additional form-definition syntax outside of what PF handles
PagesOnDemand 0.1 PagesOnDemand Hook for modules that create new pages from templates when links to nonexistent pages are followed
Renameuser 1.11 RenameUserAbort Allow other extensions to abort a user rename
Renameuser 1.11 RenameUserComplete After a successful user rename
Renameuser 1.13 RenameUserPreRename Before renaming a user
Renameuser r55189 RenameUserSQL In the constructor of RenameuserSQL class, allows adding tables to the array of tables that Renameuser should update on rename
Renameuser 1.13 RenameUserWarning Get warnings when renaming a user
Shibboleth Authentication ShibUpdateUser Hook event called before user information gets updated on login (for setting the name/mail from Shibboleth)
SphinxSearch 0.7.2 r73342 SphinxSearchBeforeResults Control various search parameters before search client is instantiated
SphinxSearch 0.7.2 r73342 SphinxSearchBeforeQuery Control search term and sphinx client before search is executed
UserMerge 1.6.21 1.19 r89147 DeleteAccount Trigger update actions elsewhere (e.g. in OpenID) when UserMerge has deleted an account
UserMerge 1.6.21 1.19 r89147 MergeAccountFromTo Trigger update actions elsewhere (e.g. in OpenID) when UserMerge has merged one account to another

Extensions : Category All RequestsTag extensions Extensions FAQ Extension hook registryExtension default namespaces