Manual:Hooks/BeforePageRedirect

From MediaWiki.org
Jump to navigation Jump to search
BeforePageRedirect
Available from version 1.19.0
Called prior to sending an HTTP redirect
Define function:
public static function onBeforePageRedirect( $out, &$redirect, &$code ) { ... }
Attach hook:

In extension.json:

{
	"Hooks": {
		"BeforePageRedirect": "MyExtensionHooks::onBeforePageRedirect"
	}
}

For MediaWiki ≤1.25:

$wgHooks['BeforePageRedirect'][] = 'MyExtensionHooks::onBeforePageRedirect';
Called from:File(s): OutputPage.php

For more information about attaching hooks, see Manual:Hooks.
For examples of extensions using this hook, see Category:BeforePageRedirect extensions.

Gives a chance to override how the redirect is output by modifying, or by returning false and taking over the output.

  • $out: OutputPage object
  • &$redirect: URL string, modifiable
  • &$code: HTTP code (eg '301' or '302'), modifiable