Manual:Hooks/getUserPermissionsErrors

From MediaWiki.org

Jump to: navigation, search
getUserPermissionsErrors
Available from version 1.12.0
Add a permissions error when permissions errors are checked for.

*Define function:
function fnMyHook( $title, $user, $action, &$result ) { ... }

*Attach hook:
$wgHooks['getUserPermissionsErrors'][] = 'fnMyHook';
Called from: Title.php

*For more information about attaching hooks, see Manual:Hooks.
*For examples of extensions using this hook, see Category:getUserPermissionsErrors extensions.


[edit] Details

  • $title: Title object being checked against
  • $user : Current user object
  • $action: Action being checked
  • &$result: User permissions error to add. If none, return true. $result can be returned as a single error message string, or an array of error messages of multiple messages are needed.

[edit] Differences from getUserPermissionsErrorsExpensive

Both hooks are typically run when checking for proper permissions in Title.php. When it is desireable to skip potentially expensive cascading permission checks, only getUserPermissionsErrors is run. This behavior is suitable for nonessential UI controls in common cases, but not for functional access control. This behavior may provide false positives, but should never provide a false negative.