16 February 2007
Disable Anonymous Editing in MediaWiki
Posted by Mikhail Esteves under: LAMP; Miscellaneous; Tips .
If you want to disable Anonymous editing in MediaWiki, here is one way to do it:
- Edit
LocalSettings.phpand add the following setting:
$wgDisableAnonEdit = true;
- Edit
includes/SkinTemplate.php, find$fname-editand change the code to look like this (i.e., basically wrap the following code between thewfProfileIn()andwfProfileOut()functions):
wfProfileIn( "$fname-edit" );
global $wgDisableAnonEdit;
if ( $wgUser->mId || !$wgDisableAnonEdit) {
// Leave this as is
}
wfProfileOut( "$fname-edit" );
Next, you may want to disable the [Edit] links on sections. To do this, open includes/Skin.php and search for editsection. You will see something like:
if (!$wgUser->getOption( 'editsection' ) ) {
Change that to:
global $wgDisableAnonEdit;
if (!$wgUser->getOption( 'editsection' ) || !$wgDisableAnonEdit ) {
Section editing is now blocked for Anonymous users.
3 Comments so far...
Tony Says:
26 February 2007 at 7:01 pm.
This is a better solution:
By adding the following line to LocalSettings.php, it is possible to entirely disable anonymous edits:
Pre-1.5:
- Entirely disable Anonymous Edits in Wiki versions 1.4 and before
$wgWhitelistEdit = true;
Note that you have to add this to the end of the LocalSettings.php file, just above the closing “?>” for it to work properly.
1.5 upwards:
- This snippet prevents editing from anonymous users
$wgGroupPermissions[’*’][‘edit’] = false;
From http://meta.wikimedia.org/wiki/Preventing_Access#Disable_anonymous_edits
Héctor Carrasco Says:
13 September 2007 at 10:24 am.
Thanks, just one thing: please be care about the quotation marks. They look similar but are different
$wgGroupPermissions[’*’][‘edit’] = false;
$wgGroupPermissions[’*’][‘edit’] = false;
ch__ Says:
25 November 2007 at 8:39 pm.
Thanks for the tip, now I’m starting to understand how does the whole thing work…