Manual:Hooks/userCan

Details

 * $title : Title being checked
 * $user : Current user
 * $action : Action being checked
 * $result : Reference to result

To set a result, set the value of $result, e.g. to indicate that the user should not be allowed to perform the specified action, set $result to false.

Return true from the hook function to continue the hook chain. This allows other functions subscribed to the hook to set their own value. Returning false will halt hook chain processing. In general, if setting $result to false, one should also return false; if setting $result</tt> to true</tt>, or not setting a value, one should return true</tt> to allow other extensions to validate the action.

If a result is returned from an extension in the hook chain, internal checks are not performed. If no result is returned, i.e. $result</tt> remains null</tt>, then the rest of Title::userCan</tt> is run, and internal checks are performed.

Permutations
For convenience, a table is provided below which summarises the possible permutations of $result</tt> and the return value, and details the consequences.

Note - Unlike most other hooks, you cannot return a string value from the userCan hook. Normally, returning a string value will cause an error page to be displayed, containing the returned string. However, the process of displaying the error page calls the userCan hook to determine the available UI elements, and so returning a string from this function will cause an infinite recursion! This was tested on v1.6.10 and may have subsequently been fixed.