PUBLISHED : |sinon_interdire_acces

**SPIP**

# Article validated

The article "**|sinon\_interdire\_acces**
(https://www.spip.net/en_article6612.html)" was validated by
<multi>[ar]جورج[fr]George [en]George</multi>.

* * *

## |sinon\_interdire\_acces

Saturday 10 October 2020 , by [jack](.././?page=auteur&id_auteur=593&)

## Table of contents

* See also

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.

1. [ ( #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 [|Back to the table of contents](#s-See-also)

**Other test filters**

* |oui (https://www.spip.net/ecrire/?exec=article&id_article=4984)
* |non (https://www.spip.net/ecrire/?exec=article&id_article=4985)
* |?*ifyes, ifnot*
(https://www.spip.net/ecrire/?exec=article&id_article=5024)
* |sinon (https://www.spip.net/ecrire/?exec=article&id_article=4966)

**logical filters**

* |et (https://www.spip.net/ecrire/?exec=article&id_article=4953)
* |ou (https://www.spip.net/ecrire/?exec=article&id_article=4952)
* |xou (https://www.spip.net/ecrire/?exec=article&id_article=4951)

[1] See the description of the tag #AUTORISER
(https://www.spip.net/ecrire/?exec=article&id_article=5103) and the
corresponding API
(https://www.spip.net/ecrire/?exec=article&id_article=6599).

— Sent by SPIP (https://www.spip.net/)

rubon199-7e493.jpg