Manual:Hooks/ApiOptions

From MediaWiki.org
Jump to navigation Jump to search
ApiOptions
Available from version 1.33.0 (Gerrit change 447730)
Called by action=options before applying changes to user preferences.
Define function:
public static function onApiOptions( ApiOptions $apiModule, User $user, array $changes, array $resetKinds ) { ... }
Attach hook:

In extension.json:

{
	"Hooks": {
		"ApiOptions": "MyExtensionHooks::onApiOptions"
	}
}

For MediaWiki ≤1.25:

$wgHooks['ApiOptions'][] = 'MyExtensionHooks::onApiOptions';
Called from:File(s): api/ApiOptions.php
Function(s): execute

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

Details[edit]

  • $apiModule: Calling ApiOptions object
  • $user: User object whose preferences are being changed
  • $changes: Associative array of preference name => value
  • $resetKinds: Array of strings specifying which options kinds to reset. See User::resetOptions() and User::getOptionKinds() for possible values.