Knowledgebase

How to disable the options for user preferences in MediaWiki

There's a default configuration of options that's applied to users on your MediaWiki site. For example, by default when a user opens the Recent changes page the last 50 edits are listed. There are many such user options that registered users can change so that the configuration that the user sets up is applied specifically to that user when he/she logs in. After a registered user logs into their account they can set up these preferences to be applied for their account from the Preferences button. It's usually in the top right corner of the page but this depends on the skin. From the account preferences the user can configure various options related to the email function, the date format, the skin, the watchlist, the Recent changes page, etc.

If you want to, you can prevent users from configuring any of the user preferences. It's also possible to prevent users from editing only specific options. In this article we'll mainly concentrate on disabling all user preferences, but we'll also show the principle of hiding only specific options.

  • You can disable all user preferences by removing the respective user right from user groups. So this is done per user group, meaning that you can disable user preferences only for specific groups and allow other user groups to edit their account options. This is done in the same way as removing any other user right; you only have to put the exact label for the permission for editing user preferences. It's editmyoptions. So to disable user preferences for a user group you have to put in the LocalSettings.php file of your MediaWiki a line with the following form:

$wgGroupPermissions['name-of-group']['editmyoptions'] = false;

Replace name-of-group with the actual name of the group for which you want to disable user preferences. So, for example, if you put the following in LocalSettings.php:

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

this will disable user preferences for all users. Note that from the default user groups that come preconfigured with MediaWiki this user right is added only to the group to which all users belong (the all group which in the files is labeled with *). The other groups don't have this right specifically added. This means that you cannot remove that right only from one of these groups (e.g. the group of the registered users, the group of the administrators). It also means that when you remove the right with the above line, all users, including administrators, will not be able to edit their user preferences. What you can do is to remove the right as shown above and then specifically add it to those user groups that you want to be able to edit their user preferences. This is done in the same way; you only have to replace false with true and put in the first pair of brackets the name of the user group. For example:

$wgGroupPermissions['sysop']['editmyoptions'] = true;

will explicitly give the permission to edit their user preferences to the group of the sysops/administrators.

For detailed information on how to manage user groups and permissions, including the exact labels of the default groups, check out the tutorial on how to manage users, user groups and permissions in MediaWiki.

  • It's also possible to hide only specific options from the user preferences. This is again done by adding lines to the LocalSettings.php file. It's achieved with the help of the variable $wgHiddenPrefs. You have to specify the name of each option that you want to remove from the user preferences. Each option has an exact label that has to be used. For example, adding the following to LocalSettings.php:

$wgHiddenPrefs[] = 'date';

will remove the option with which users can change the date format. If you want to remove more options you can add more lines to the LocalSettings.php file and put the label for the option in the quotation marks. Of course, this means that you have to know what the label for the option is. The labels for the options are specified in the file DefaultSettings.php (around line 4257); to find them search for the variable $wgDefaultUserOptions inside the file. The file DefaultSettings.php is inside the includes folder of your MediaWiki which itself is in the root MediaWiki directory on your hosting account. If, for example, the application is installed directly in the public_html directory on your MediaWiki hosting account, then the path to the file will be public_html/includes/DefaultSettings.php. Don't modify that file.

The LocalSettings.php file that you can modify to disable user preferences is in the root MediaWiki folder. HostKnox customers can view and edit files on their hosting account from the Files section of the Pixie control panel. A different way to do it is to download the file on your local computer, edit it with a text editor (e.g. Notepad) and upload it back. It can also be done via SSH.

Was this answer helpful?

 Print this Article

Also Read