Manuel:Préférences utilisateur

This page is a translated version of the page Manual:User preferences and the translation is 36% complete.

Récupérer les préférences utilisateur

To retrieve all of a user's preferences, use UserOptionsLookup::getOptions() with a user identity object as a parameter.

To retrieve a specific preference of a user, use UserOptionsLookup::getOption() with a user identity and the name of the preference as a parameter, for example:

$emailFrequency = MediaWikiServices::getInstance()->getUserOptionsLookup()->getOption( $this->getUser(), 'echo-email-frequency' );

If the preference is of the multiselect or checkmatrix type, the parameter will be <preference-name><option-value>. For example, if the preference name is 'searchNs' and the option value is '2', the parameter for getOption will be 'searchNs2'. There is an exception to this, however: If the preference specifies an explicit option prefix, that prefix will be used instead of the preference name (<prefix-name><option-name>). See the Gadgets extension for an example.

To retrieve it in JavaScript, use the user.options module.

Définir les préférences par défaut

For information about how to set default preferences for all users, see Manuel:$wgDefaultUserOptions .

Modifier une préférence

Preferences can be changed through the [[Special:MyLanguage/API:Options|String Module Error: Match not found]] API action.

Créer une interface de préférences

For information about creating a preferences interface for your features, see Manuel:Accroches/GetPreferences .

Gadget and user script preferences

Any gadget or user script can define a preference, the name of which must start with "userjs-". Such a preference will not appear in Special:Preferences or in API:Userinfo responses, and it will not be validated. It can be read from user.options , and set through API:Options .

Préférences masquées d'API

API preferences are also defined through the GetPreferences hook, with the type set to 'api'. They are validated and readable the normal ways, but are not part of the Special:Preferences form.

Disabling user preferences

By preference

Version de MediaWiki :

To disable individual preferences for all users, add preference names to the $wgHiddenPrefs configuration variable. For example, to prevent everyone from being able to mark their edits minor by default, set the following in your LocalSettings.php:

$wgHiddenPrefs[] = 'minordefault';

Par groupe d'utilisateurs

Version de MediaWiki :

To prevent individual user groups from editing their preferences, you can use the 'editmyoptions' user right. With this line in your LocalSettings.php, users in the group 'user' (which contains all logged in users) can't edit their user preferences:

$wgGroupPermissions['user']['editmyoptions'] = false;

Par utilisateur

It is not possible to disable only certain individual users' preferences.

Voir aussi