Recent Changes - Search:

Cookbook

PmWiki

pmwiki.org

LimitNewPagesInWikiGroups

Summary: How to limit the creation of new pages in your wiki group
Version: 2007-02-27
Prerequisites:
Status:
Maintainer:
Categories: Administration

Questions answered by this recipe

Can I limit, block or constrain adding or creating new pages in wiki groups?

Can I prevent users from creating new pages?

Description

The following code added to config.php will disallow creation of new pages in any group with a name beginning with "TODO".

array_unshift($EditFunctions, 'CreateDisallowed');

function CreateDisallowed($pagename, $page, $new) {
   global $EnableCreatePages, $EnablePost, $MessagesFmt;
   if (IsEnabled($EnableCreatePages, 1)) return;
   if (PageExists($pagename)) return;
   Redirect('Main.PageCreationError'); #or some other page,
# or use next two code lines instead of the Redirect above
#   $EnablePost = 0;
#   $MessagesFmt[] = 'Creation of new page blocked';
  }

if (preg_match('/^TODO/', $pagename))
   $EnableCreatePages = 0; 

To disallow new page creation for a specific group, you could either put all the code except the line

 if (preg_match('/^TODO/', $pagename))

into the group's local php file: local/GroupName.php,

or replace

if (preg_match('/^TODO/', $pagename))
   $EnableCreatePages = 0; 

with

$group = PageVar($pagename, '$Group');
if($group=='GroupName') $EnableCreatePages = 0; 

How do I require a password to create a new page, but allow edits to existing pages to proceed without a password

Notes

Release Notes

If the recipe has multiple releases, then release notes can be placed here. Note that it's often easier for people to work with "release dates" instead of "version numbers".

Comments

See Also

Contributors

Edit - History - Print - Recent Changes - Search
Page last modified on January 29, 2008, at 01:18 PM