How to edit the account options of all users in MediaWiki
In MediaWiki there are account options that each registered user can configure for their account to the values they want. The changes that a user makes apply only to the account of that user. If for some reason you want to set one or more options from the user preferences to a particular value and apply it to the accounts of all registered users, you can do that with the help of a script file that comes prepackaged with MediaWiki.
To change the value for an account option for all users you have to execute that script with a command. This is done via SSH. All HostKnox customers have free SSH access to their accounts as part of their hosting plan. For more information on how to connect via SSH check out the tutorial on how to connect to your account via SSH. In the SSH section of our knowledge base you'll find articles related to managing your account via SSH.
The script with which you can change user options is called userOptions.php and it's in the maintenance directory of your MediaWiki. Let's say that before you execute the script, for the sake of convenience you change the current working directory to the maintenance folder. It's in the root directory of your MediaWiki. We'll assume that the application is installed directly in the public_html directory on your account. When a HostKnox customer logs into their account via SSH the directory into which they are logged is a parent directory to public_html. So to change the current working directory to the maintenance folder, right after you log in you have to execute the command cd public_html/maintenance. In this way when you execute the userOptions.php script you don't have to include the path to the script in the command.
View the User Options and their Default Values
Before you actually change an option it's a good idea to view the existing user options and their default values. You can do this with the same userOptions.php script by adding the option --list to the command:
php userOptions.php --list
This will display a list with the current user options and the default value for each option. In that list you can also check the exact name of the option(s) that you want to edit. That's the name that you have to use in the command for changing the value for the option. Note that if you don't change the current working directory to the maintenance folder, you have to include the path to the userOptions.php file in the command (e.g. php public_html/maintenance/userOptions.php --list).
Most of the user options can be either disabled or enabled, meaning that they can have one of two possible values (there are also a few options with numerical values). So in the list with the options the values for such options are represented with 0 and 1; 0 stands for disabled and 1 for enabled. All the existing user options and their default values are defined in the file DefaultSettings.php. It's located in the includes folder. You can also check the options there but it will be easier just to execute the above command that we discussed.
Change the Values of User Options
Changing the value of a user option for all users is done with a command similar to the above one. You only have to add the name of the option, it's old/existing value and the new value that you want to set. The command has the following syntax:
php userOptions.php [name of option] --old [old value] --new [new value]
You have to replace the brackets with the actual values. So let's say that you want to enable the option Auto-number headings that's on the Appearance page of the user preferences on the frontend of the site. The name of that option as defined in the code of the files is numberheadings. You have to change it from the default value 0 (meaning disabled) to 1 (i.e. enabled). You can do this with the command:
php userOptions.php numberheadings --old 0 --new 1
If there are users for whom the option is disabled, the command will enabled it.