Open main menu

Extension talk:Lockdown

About this board

Archive 1

Serek (talkcontribs)

I am trying to set:

$wgNamespacePermissionLockdown[0]['createpage'] = array( 'bureaucrat', 'sysop' );

but it does not seem to work. Is it possible at all to limit page creation only? MW 1.31.1

AhmadF.Cheema (talkcontribs)
Reply to "createpage only permissions?"

Namespace lockdown doesn't work correctly in MW 1.31

Maude's Ideology (talkcontribs)

Use this instead, in your LocalSettings.php, to limit the NS_PRIVATE and NS_PRIVATE_TALK namespaces to WikiSysop and User2.

$wgHooks['ParserBeforeStrip'][] = 'LockDownFunction';
function LockDownFunction( &$parser, &$text, &$strip_state ) {
        global $wgUser;
        $title = $parser->getTitle();
        $namespace = $title->getNamespace();
        if ( $namespace === NS_PRIVATE || $namespace === NS_PRIVATE_TALK ) {
                $user = $parser->getUser();
                $userName = $user->getName();
                $allowed = array(
                if ( in_array( $userName, $allowed )
                        || in_array( $wgUser, $allowed )
                ) {
                        return true;
                } else {
                        die("Access denied");
2003:D2:DBC6:8A00:ECEA:9E8D:EF51:E302 (talkcontribs)

This is Great but you have to reverse the order in in_array for it to work

in_array( $userName, $allowed )

should to be

in_array( $allowed, $userName )

Thank you so much ! I have been so tired of deprecated Extensions that dont work.

BabunaLaguna (talkcontribs)
## //Restrict namespace access to group privat 
$wgHooks['ParserBeforeStrip'][] = 'LockDownFunction';
function LockDownFunction( &$parser ) {
    $title = $parser->getTitle(); 
    $namespace = $title->getNamespace(); 
    //Groups in here are allowed to access
    $allowedgroups = 'privat'; 
    //Restricted namespaces
    $wgLockedNamespaces = array( '3000', '3001' ); 
    if ( in_array($namespace, $wgLockedNamespaces) ) { 
        $user = $parser->getUser(); 
        $userGroups = $user->getGroups(); 
        if ( !in_array( $allowedgroups, $userGroups )) { 
            die("<h1>Access denied, you dont have the necessary permissions to access this namespace.</h1>");
        return true;
AhmadF.Cheema (talkcontribs)

The directly above method noted by User:BabunaLaguna does not work when submitting an edit (&action=submit) to the protected namespace and instead throws out the "Access denied..." message at the end. (talkcontribs)

Tested MW 1.31.0 on PHP 7.2.12 with Lockdown (dbd06b7). Wanted to lock one namespace and talk (198 and 199). This locked all pages in the wiki! But when using array_fill in LocalSettings.php, it seems to work:

$defaultreadall['read'] = array('*');

$wgNamespacePermissionLockdown = array_fill(0,2010,$defaultreadall);

$wgNamespacePermissionLockdown[NS_INTERNAL]['read'] = array('MyAllowedGroup');

$wgNamespacePermissionLockdown[NS_INTERNAL_TALK]['read'] = array('MyAllowedGroup');

The problem was, that the Lockdown-hook sees the global array wgNamespacePermissionLockdown as a collapsed one with empty indexes removed. Instead of [198, 192] it was only [0,1] as array keys.

Reply to "Namespace lockdown doesn't work correctly in MW 1.31"

Use of lowercase letter in compound words of special page names

Deltaray3 (talkcontribs)

Just something to note that wasn't clear at first until I read this talk page which gives some more examples. For some special page names, only the first character is capitalized and the rest of the word is all lowercase. For example, the page is called "Special:ListUsers" in MediaWiki, but you need to call it "Listusers" (lowercase u) in the config file for it to work. This contradicts the naming of the special pages by Mediawiki. Thanks for this extension.

Kghbln (talkcontribs)

Thanks for the note. However this is already documented on the extension's page There is also a difference between internal naming and user facing naming. Yeah, indeed a bit complicated at the beginning.

Reply to "Use of lowercase letter in compound words of special page names"

MW 1.31 - Error 500 with Lockdown

2 (talkcontribs)

When i put in my LocalSettings.php the expresison "wfLoadExtension( 'Lockdown' );", and i try access the main page, the server returns "ERROR 500". (talkcontribs)

lockdown is incompatible with WM 1.30, it seems accesscontrol extension either

Reply to "MW 1.31 - Error 500 with Lockdown" (talkcontribs)

I am trying to get Lockdown to work on MW 1.30. After installing the git master, it show up under Special:Version. When trying to limit read access to a custom namespace with this config:

$wgNamespacePermissionLockdown[3002]['read'] = array('sysop');

actually the main namespace is limited to sysops and the custom namespace is not locked down. I was not able to lockdown the custom namespace at all. Any suggestions? Thx, Marc

Bevenson (talkcontribs)

Were you able to get this to work?

Reply to "Working on MW 1.30?"

Issues in MW 1.27.4: Namespace completely ignored, always affects main and main talk only

Redeemer (talkcontribs)

I downloaded and installed the MW 1.27 version in MW 1.27.4. Either, I'm not understanding the extension properly, or it does not work.

Minimal and pointless example: I'm trying allow editing in namespace 2 (user) for bots only, so I added

$wgNamespacePermissionLockdown[2]['edit'] = array('bot');

to the end of my LocalSettings.php as the only Lockdown-related line. As the result, only bots are allowed to edit namespaces 0 (main) and 1 (talk) while everyone is still able to edit the user namespace. Generally, no matter what namespace I enter, Lockdown always affects namespace 0 and 1 only.

Reply to "Issues in MW 1.27.4: Namespace completely ignored, always affects main and main talk only"
TheRebel~mediawikiwiki (talkcontribs)

I was having problem with locking down certain special pages based on user groups with Lockdown on MW 1.17 and 1.16. Here is a solution that doesn't need Lockdown at all, just enter this in your LocalSettings.php:

function SpecialPageBlock(&$list){
global $wgUser;
if (in_array('sysop', $wgUser->getGroups()) == 0){
)as $i){unset($list[$i]);}}
return true;}

The example above limits access to the pages listed in the array to the 'sysop' group, by removing the pages from the rest of the groups. The best thing in this solution is that the pages in the array won't even show up on the SpecialPages.

For some reason Random and MostLinkedPages couldn't be disabled this way, any ideas why?

This post was posted by TheRebel~mediawikiwiki, but signed as TheRebel. (talkcontribs)

Thanks! A much better solution. People don't even know what they're missing. (talkcontribs)

This works perfectly. This should be linked to from restricting access pages. Thanks a bunch.

Frantik (talkcontribs)

Here is a function which allows you to specify various user groups and also whitelist pages, as opposed to having to list every single page to block.

function SpecialPageBlock(&$list)
	global $wgUser;
	$allowedGroups = array(
	$whiteList = array(

	$allowed = false;
	$userGroups = $wgUser->getGroups();	
	foreach($allowedGroups as $group)
		if (in_array($group, $userGroups))
			$allowed = true;
	if (!$allowed)			
		foreach($list as $key => $specialPage)
			if (!in_array($key, $whiteList))
	return true;

Kghbln (talkcontribs)

Thanks a lot for sharing! Much apprechiated!

Reply to "Locking down special pages"
Summary by Kghbln

Docu was updated.

Alvarosaurus (talkcontribs)

Hi, it appears that Lockdown.php has been deleted from the 1.27 version.

Kghbln (talkcontribs)
JamesJeko (talkcontribs)

Hi all,

When I try to restrict (validate) perrmision on a specific namespace, it does not work. But it still works on other permissions such as (Edit, Delete, Read). So, is there any way to solve these problems? thanks

Reply to "Lockdown (validate) permission"
Calion (talkcontribs)
Kghbln (talkcontribs)

You can. That's not even Lockdown specific.

Calion (talkcontribs)

To the Manual page?

Reply to "Error in Page"
Return to "Lockdown" page.