Manual:Hooks/UserSaveOptions

From MediaWiki.org
Jump to navigation Jump to search
UserSaveOptions
Available from version 1.16.0
Called just before saving user preferences. Hook handlers can either add or manipulate options, or reset one back to its default to block changing it. Hook handlers are also allowed to abort the process by returning false, e.g. to save to a global profile instead. Compare to the UserSaveSettings hook, which is called after the preferences have been saved.
Define function:
public static function onUserSaveOptions( User $user, array &$options ) { ... }
Attach hook:

In extension.json:

{
	"Hooks": {
		"UserSaveOptions": "MyExtensionHooks::onUserSaveOptions"
	}
}

For MediaWiki ≤1.25:

$wgHooks['UserSaveOptions'][] = 'MyExtensionHooks::onUserSaveOptions';
Called from: File(s): User.php

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

Details[edit]

  • $user: The User for which the options are going to be saved
  • &$options: The users options as an associative array, modifiable

See also[edit]