MediaWiki User Management

From Fishcakes Wiki

Jump to: navigation, search
Edit Menu

Image:Icon_Mediawiki_40px.png MediaWiki User Management

This page contains info about restricting users from viewing and/or editing a Wiki.

Contents

About User Management

Restrict User Access

Edit Settings File

In order the restrict viewing and editing of pages you have to set the User Management variables in LocalSettings.php located in the root folder. Open this file and add the additional settings to the bottom of the file:

# Custom Settings by Dan Salmon
# Last update Sat 14 Jul 07
$insert code here...

Never edit includes/DefaultSettings.php, just copy appropriate lines to LocalSettings.php instead and amend them as appropriate.

Restrict account creation

# Prevent new user registrations except by sysops
$wgGroupPermissions['*']['createaccount'] = false;

New can be created by sysops, in the following manner:

  1. Go to [[Special:Userlogin]] when logged in as a sysop. Special:Userlogin
  2. Click on "Create an account" to get to the account creation form.
  3. Enter a username and an email address, and click the "by email" button.
  4. The account will be created with a random password which is then emailed to the given address.

Restrict editing of all pages

# Disable anonymous editing
$wgGroupPermissions['*']['edit'] = false;
# Disable editing by all non-sysop users
$wgGroupPermissions['*']['edit'] =
$wgGroupPermissions['user']['edit'] = false;
$wgGroupPermissions['sysop']['edit'] = true;
# Disable editing by absolutely everyone
$wgGroupPermissions['*']['edit'] =
$wgGroupPermissions['user']['edit'] = 
$wgGroupPermissions['sysop']['edit'] = false;

Restrict editing of an entire namespace

# Only allow autoconfirmed users to edit Project namespace
$wgNamespaceProtection[NS_PROJECT] = array( 'autoconfirmed' );
# Don't allow anyone to edit non-talk pages until they've confirmed their
# e-mail address (assuming we have no custom namespaces and allow edits
# from non-emailconfirmed users to start with)
$wgNamespaceProtection[NS_MAIN]     = $wgNamespaceProtection[NS_USER]  =
$wgNamespaceProtection[NS_PROJECT]  = $wgNamespaceProtection[NS_IMAGE] =
$wgNamespaceProtection[NS_TEMPLATE] = $wgNamespaceProtection[NS_HELP]  =
$wgNamespaceProtection[NS_CATEGORY] = array( 'emailconfirmed' );
# Only allow sysops to edit "Policy" namespace
$wgGroupPermissions['sysop']['editpolicy'] = true;
$wgNamespaceProtection[NS_POLICY] = array( 'editpolicy' );

Note that in the last case it's assumed that a custom namespace exists and that NS_POLICY is a defined constant equal to the namespace number.

Restrict page creation

# Anonymous users can't create pages
$wgGroupPermissions['*']['createpage'] = false;
# Only users with accounts four days old or older can create pages
# (like Wikipedia!).  Requires MW 1.6 or higher.
$wgGroupPermissions['*'            ]['createpage'] =
$wgGroupPermissions['user'         ]['createpage'] = false;
$wgGroupPermissions['autoconfirmed']['createpage'] = true;
$wgAutoConfirmAge|$wgAutoConfirmAge = 86400 * 4; # Four days times 86400 seconds/day

Restrict viewing of all pages

# Disable reading by anonymous users
$wgGroupPermissions['*']['read'] = false;
# But allow them to read the Main Page, login page, and JS/CSS pages
$wgWhitelistRead = array( ":Main Page", "Special:Userlogin", "-", "MediaWiki:Monobook.css" );

The $wgWhitelistRead setting allows users to view the main page and log in. Without this line, no one can log in. If page names have more than one word, use a space " " between them, not an underscore "_".

Image:Icon Resources 20px.png MediaWiki Resources

Official MediaWiki Resources

Unofficial MediaWiki Resources

Media Wiki Tools


Personal tools