Manual:Hooks/SavePreferences

From MediaWiki.org
Jump to navigation Jump to search
SavePreferences
Available from version 1.11.0
Removed in version 1.16.0
called at the end of PreferencesForm::savePreferences(); returning false prevents the preferences from being saved.
Define function:
public static function onSavePreferences( $form, $user, &$message, $old ) { ... }
Attach hook:

In extension.json:

{
	"Hooks": {
		"SavePreferences": "MyExtensionHooks::onSavePreferences"
	}
}

For MediaWiki ≤1.25:

$wgHooks['SavePreferences'][] = 'MyExtensionHooks::onSavePreferences';
Called from:File(s): SpecialPreferences.php

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

Details[edit]

  • $form: the PreferencesForm
  • $user: the User object to save preferences to
  • &$message: change this to set an error message (ignored if the hook does not return false)
  • $old: array of old options (added in 1.13)