User:Barrylb/Usercan Hook
From MediaWiki.org
|
Barrylb/Usercan Hook Release status: unknown |
|
|---|---|
| Implementation | User rights |
| Description | modifies user rights |
| Author(s) | User:Barrylb |
| Download | no link |
| Hooks used | |
You can restrict access to certain MediaWiki features without modifying the core files using the userCan hook available since version 1.6.0. Tested and working on version 1.6.7 and 1.7.1.
Note the 'userCan' hook for 'edit' actions acts in addition to any other security checks so if you have this $wgGroupPermissions['*']['edit'] = false; in your LocalSettings.php then it will act in addition, and disable anonymous editing entirely.
Put one the following in your LocalSettings.php file depending on your needs:
[edit] Limit non-logged-in users to editing talk pages only
function fnMyUserCan($title, $user, $action, $result) { if ($action == 'edit') { if (!$title->isTalkPage() && !$user->isLoggedIn()) $result = false; } } $wgHooks['userCan'][] = 'fnMyUserCan';
[edit] Any user can edit talk pages. Only Sysop can edit other pages
function fnMyUserCan($title, $user, $action, $result) { if ($action == 'edit') { if (!$title->isTalkPage() && !$user->isSysop()) $result = false; } } $wgHooks['userCan'][] = 'fnMyUserCan';
[edit] Non-logged-in users can view source but not edit
function fnMyUserCan($title, $user, $action, $result) { if (($action == 'edit') && !$user->isLoggedIn()) $result = false; } $wgHooks['userCan'][] = 'fnMyUserCan';
Last change 22:23, 16 July 2006 (UTC)

