From mediawiki.org
Jump to navigation Jump to search
MediaWiki extensions manual
OOjs UI icon advanced.svg
Release status: unmaintained
Implementation User activity
Description Provides the ability to limit the creation of new users based on user count
Author(s) witerate
Latest version 1.0
MediaWiki 1.17-1.19
MediaWiki 1.36 Not formally tested
MediaWiki 1.34 Not formally tested
MediaWiki 1.32 Not formally tested
License No license specified
Download see below

Check usage and version matrix.

LimitUserCount is a MediaWiki extension which provides the ability to limit the creation of new users based on user count.

It checks the current number of users in your Media Wiki and prevents on creating a new user if that number surpasses $wgLimitUserCount.


When you start managing a wiki farm with tens or even hundred of wikis, and you want to control the number of registered users on each wiki without actually opening yourself each account, this extension can help you a lot.

Installation and usage[edit]

  1. Copy LimitUserCount.php to your Media Wiki extensions folder.
  2. Add the following lines at the end of LocalSettings.php:
       require_once( "$IP/extensions/LimitUserCount.php" ); 
       $wgLimitUserCount = 10;

(In the above example, only 10 users will be allowed in the Wiki)

Source of LimitUserCount.php[edit]

 * LimitUserCount - MediaWiki extension
 * provides the ability to limit the creation of new users based on user count
$wgHooks['AbortNewAccount'][] = 'LimitUserCount';
$wgExtensionMessagesFiles['LimitUserCount'] = dirname( __FILE__ ) . '/LimitUserCount.i18n.php';

function LimitUserCount( $user, $message ) {
	global $wgLimitUserCount;
	if( !is_int( $wgLimitUserCount ) ) {
		return true; # no or invalid limit
	$dbr = wfGetDB( DB_SLAVE );
	$numUsers = $dbr->selectField( 'user', 'COUNT(*) AS numusers', array(), __METHOD__ );
	$message = wfMsg( 'limitusercount-message', $wgLimitUserCount );
	return $numUsers < $wgLimitUserCount;
  * Add extension information to Special:Version
$wgExtensionCredits['other'][] = array(
	'name' => 'LimitUserCount',
	'version' => '1.0',
	'author' => array( 'Gregory Rashkevitch, Witerate.com Software Solutions', 'SPQRobin' ),
	'descriptionmsg' => 'limitusercount-desc',
	'url' => 'https://www.mediawiki.org/wiki/Extension:LimitUserCount',

$wgLimitUserCount = false;
 * Internationalisation file for extension NewUserMessage.
 * @file
 * @ingroup Extensions

$messages = array();

$messages['en'] = array(
	'limitusercount-message' => 'Cannot create user, the maximum number of users allowed on this wiki has been exceeded!',
	'limitusercount-desc' => 'Enable limitation on user creation based on users count',

$messages['fr'] = array(
	'limitusercount-message' => 'Ne peut pas créer l´utilisateur, le nombre maximum d´utilisateurs permises sur ce wiki est dépassé!',
	'limitusercount-desc' => 'Permet de limiter les créations des utilisateurs basé sur le nombre d´utilisateurs',

$messages['nl'] = array(
	'limitusercount-message' => 'Kan de gebruiker niet aanmaken, want het maximum aantal gebruikers op deze wiki is bereikt!',
	'limitusercount-desc' => 'Laat beperking van nieuwe gebruikers toe volgens het aantal bestaande gebruikers',


  1. $wgLimitUserCount - Defines the maximum user count allowed in the Wiki.
  2. The 'limitusercount-message' message which you can alter. You can find it here - [[MediaWiki:Limitusercount-message]]

To do[edit]

  1. Consider extra parameters in the users count - bots, admins, blocked users