Manual talk:Hooks/GetPreferences

From mediawiki.org
Latest comment: 8 years ago by Nonstandard in topic Default?

Here's an example how to make use of a preference:

$user = $this->getUser(); 
if ( $user->getOption( 'mypref2' ) == 'choice3' ) { /* do something... */ }

Default?[edit]

I see this line in the example for a radio button:

		'default' => 'choice1',  // A 'default' key is required!

but I think that actually one shouldn't put a 'default' key in this structure: you should leave it to the Preferences class to assign 'default' to whatever the user's preference choice is. If you provide 'default' in this way, it will always display the value you list even if the user has actually chosen a different value! Please correct me if I'm wrong about this. - Nonstandard (talk) 02:02, 21 April 2015 (UTC)Reply