LimitNewPagesInWikiGroups
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
See Also
- Limit Wiki Groups
- New Group Warning : how to display a warning when a user is creating a page in a non-existant wiki group, without blocking the page creation.
Contributors
Comments
See Discussion at LimitNewPagesInWikiGroups-Talk?
User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.