Jump to navigation Jump to search
Available from version 1.16.0
Modify the selection criteria for Special:Random
Define function:
public static function onSpecialRandomGetRandomTitle( &$randstr, &$isRedir, &$namespaces, &$extra, &$title ) { ... }
Attach hook:

In extension.json:

	"Hooks": {
		"SpecialRandomGetRandomTitle": "MyExtensionHooks::onSpecialRandomGetRandomTitle"

For MediaWiki ≤1.25:

$wgHooks['SpecialRandomGetRandomTitle'][] = 'MyExtensionHooks::onSpecialRandomGetRandomTitle';
Called from:File(s): SpecialRandompage.php

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


Allows extensions to modify the selection criteria used in Special:Random and subclasses of it.

  • &$randstr: A random number string, generatated by wfRandom
  • &$isRedir: Boolean, whether or not the page to be selected should be a redirect
  • &$namespaces: An array of namespace indexes to get the page from
  • &$extra: An array of extra SQL statements added to the WHERE clause of the query
  • &$title: A Title object to redirect to if the hook returns false (must be set if the hook returns false)