How to prevent users from editing pages in MediaWiki

By default, on an open MediaWiki site everybody, including visitors/anonymous users, can edit the content of pages. Note that this does not include absolutely all pages on the site. By default, some pages, such as the special pages with tools and reports, cannot be edited. If you want to restrict the editing of pages, there are a few ways you can do that. You can disable the action for whole user groups or you can protect only particular pages; you might also find useful the feature for blocking users. In this article we'll go over these.

Prevent Particular User Groups from Editing All Pages

  • If you want to restrict the editing of all pages by users, you can do this by disabling the edit action for whole user groups. It can be for any of the preconfigured groups that come with MediaWiki and/or for custom groups that you've created. When a user group cannot edit pages it also means that it can't create new pages.

    You can restrict a user group from editing pages by inserting some code in the LocalSettings.php file of your MediaWiki. For example, with the following:

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

the right to edit pages will be disabled for unregistered users. The asterisk symbol * in the first pair of brackets corresponds to the user group to which all users belong, but the group of the registered users has the edit permission specifically enabled so registered users will not be affected. Keep in mind that if a user belongs to more than one group and a user right is disabled for one of the groups but enabled for the other, then the user will be able to perform the action. To restrict the editing of pages for other user groups simply put the label of that group between the quotation marks in the first pair of brackets. For example:

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

will prevent all registered users from editing pages. Note that since registered users belong both to this group and to the one to which all users belong (the one labeled with *) in order for them not to be able to edit pages you have to add both of the above lines with code to the LocalSettings.php file. Keep in mind that this will also affect the group of the administrators because the admin/sysop group doesn't have this right specifically enabled and they are also members of the user group (all registered users are). In such a situation if you want a particular group to be able to edit pages, you can specifically add that right to the group; you can use the same code but change false with true and put the label of the group in the first pair of brackets. For instance:

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

will enable the edit right for the sysop group (the group of the administrators). You can see what the permissions of all user groups are by going to Tools menu>Special pages button>Users and rights section>User group rights button on the frontend of the site.

For more information on the default user groups and on user rights check out the tutorial on how to manage users and user groups in MediaWiki and in particular the section on changing permissions.

The LocalSettings.php file that you have to edit to achieve these things in located in the root MediaWiki folder on your MediaWiki hosting account. If, for example, the application is installed directly in the public_html directory on your account, then the path to the file will be public_html/LocalSettings.php. One way for HostKnox customers to view and edit files directly on their accounts is from the File manager of the Pixie control panel. Another way is to download the file on your local computer, edit it with a text editor (e.g. Notepad) and upload it back overwriting the old file.

Prevent Users form Editing Particular Pages

  • If you want to prevent users from editing only particular pages, you can do that by using the Protect function of each of these pages. To do this, open the page, select the More button in the top right corner and from the drop-down menu select Protect. From the respective options on the following page you can select which user groups you want to be affected and you can protect the page from being edited and/or moved.

By default, only administrators can protect pages.

For more information on this function you can check out the section on how to protect pages in the tutorial on how to manage pages in MediaWiki.

Prevent Particular Users from Editing Pages by Blocking Them

  • Another way to prevent specific users from editing pages is to block them. Note however that this will also disable the other actions that can be performed with pages. The blocked user will only be able to read pages. To block a user, go to Tools menu in the left>Special pages button>Users and rights section on the following page>Block user button. On the form that opens you can specify the username of a registered user, in case you want to block a registered user, or the IP address of an unregistered user. There are also some other options.

For more information on this function and the associated options check out the section on how to block users in the tutorial on how to manage users and user groups in MediaWiki.

You may also find useful the articles on:

Was this answer helpful?

 Print this Article

Also Read