Manual:Hooks/userCan

Details

 * $title
 * reference to the title in question (see the use in $IP/includes/Title.php)


 * $user
 * reference to the current user (see the use in $IP/includes/Title.php)


 * $action
 * action concerning the title in question


 * $result
 * reference to the result propagated along the chain of hooks (see $IP/includes/Hooks.php)
 * $result can be left untouched, or set to truee or false, according to the opinion of the particular hook function
 * levaing unotuched means "I don't know", true means that the user is allowed, and false means that the $user is disallowed for the $action concerning the $title

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 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.

Table of combinations
For convenience, a table is provided below which summarises the possible combinations 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.