Disable Anonymous Editing in MediaWiki

If you want to disable Anonymous editing in MediaWiki, here is one way to do it:

  • Edit LocalSettings.php and add the following setting:
$wgDisableAnonEdit = true;
  • Edit includes/SkinTemplate.php, find $fname-edit and change the code to look like this (i.e., basically wrap the following code between the wfProfileIn() and wfProfileOut() 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

TonyFebruary 26th, 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:

  1. 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:

  1. This snippet prevents editing from anonymous users

$wgGroupPermissions[’*’][‘edit’] = false;

From http://meta.wikimedia.org/wiki/Preventing_Access#Disable_anonymous_edits

Héctor CarrascoSeptember 13th, 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;

Frases MotivacionalesMay 4th, 2012 at 9:02 pm

Thanks for the tip, it worked like a charm

Leave a comment

Your comment