Manual:Hooks/GetPreferences

From MediaWiki.org

Jump to: navigation, search
Warning - v1.16.0 has not been released yet. This feature may be modified or removed before final release.
GetPreferences
Available from version 1.16.0
Modify user preferences.

*Define function:
function fnMyHook( $user, &$preferences ) { ... }

*Attach hook:
$wgHooks['GetPreferences'][] = 'fnMyHook';
Called from: Preferences.php

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


[edit] Details

  • $user: User whose preferences are being modified.
  • &$preferences: Preferences description array, to be fed to an HTMLForm object

[edit] Example

$wgHooks['GetPreferences'][] = 'wfPrefHook';
 
function wfPrefHook( $user, &$preferences ) {
 
	$preferences['mypref'] = array(
		'type' => 'toggle',
		'label-message' => 'tog-mypref',
		'section' => 'personal/info',
	);
 
	return true;
}