Jump to content

Manual:Hooks/PreferencesFormPreSave

From mediawiki.org
PreferencesFormPreSave
Available from version 1.23.0 (Gerrit change 100113)
Allows last minute changes to a user's preferences (via User#setOption) before they're saved and gives a possibility to check which options were modified.
Define function:
public static function onPreferencesFormPreSave( array $formData, PreferencesForm $form, User $user, bool &$result, array $oldUserOptions ) { ... }
Attach hook: In extension.json:
{
	"Hooks": {
		"PreferencesFormPreSave": "MediaWiki\\Extension\\MyExtension\\Hooks::onPreferencesFormPreSave"
	}
}
Called from: File(s): preferences/DefaultPreferencesFactory.php
Interface: PreferencesFormPreSaveHook.php

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


Details

[edit]
  • $formData - An associative array containing the data from the preferences form.
  • $form - The PreferencesForm object that represents the preferences form.
  • $user - The User object that can be used to change the user's preferences.
  • &$result - The boolean return value of the Preferences::tryFormSubmit method.
  • $oldUserOptions - An associative array containing the old user options (before save).