The filter |sinon_interdire_acces
allows to redirect to an error page if it is applied to a variable equal to false
. This filter is often applied to the result of a #AUTORISER
[1], it can be inserted anywhere in the template, even in inclusions.
The following code will redirect to a standard error page (by default on a 403 in the private area and 404 in the public area) if the user does not have webmaster rights.
[(#AUTORISER{webmestre}|sinon_interdire_acces)]
Instead of simply redirecting the user to a standard error page, you can fill in a redirection URL as the first parameter, and specify the error code as the second parameter.
The following example checks the authorization "ecrire", which tests whether the visitor is connected and has the right to access SPIP’s private area (i.e. at least an editor or administrator status). If not, they will be redirected to the login page.
[(#AUTORISER{ecrire}|sinon_interdire_acces{#URL_PAGE{login}, 401})]
See also
Other test filters
logical filters