Skip to main content
The major AAM release is live! For questions or concerns, visit the Release Page.

Access Denied Redirect

Vasyl MartyniukAbout 1 min

Get Redirect

Get current access denied redirect preferences for a given website area.

Endpoint

GET /aam/v2/redirect/access-denied

curl --location 'https://example.xyz/wp-json/aam/v2/redirect/access-denied?access_level=role&role_id=subscriber' \
--header 'Authorization: Bearer ***'

Parameters

NameDescription
access_levelRequired. Can be either "role", "user", "visitor" or "default".
role_idConditionally required. The option is required if the access_level is "role".
user_idConditionally required. The option is required if the access_level is "user".
areaOptional. Specify "frontend", "backend" or "api". If omitted, settings for all areas are returned.
Response Sample
{
    "frontend": {
        "type": "default"
    },
    "backend": {
        "type": "default"
    },
    "api": {
        "type": "default"
    }
}

Set Redirect

Set the access denied redirect preferences.

Endpoint

POST /aam/v2/redirect/access-denied

curl --location 'https://example.xyz/wp-json/aam/v2/redirect/access-denied?access_level=role&role_id=subscriber' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer ***'' \
--data '{
    "area": "backend"
    "type": "page_redirect",
    "redirect_page_id": 2
}'

Parameters

NameDescription
access_levelRequired. Can be either "role", "user", "visitor" or "default".
role_idConditionally required. The option is required if the access_level is "role".
user_idConditionally required. The option is required if the access_level is "user".
areaRequired. Specify "frontend", "backend" or "api".
typeRequired. The type of redirect. Possible values are "custom_message", "login_redirect", "page_redirect", "url_redirect", "trigger_callback", and "default".
messageConditionally required if type is custom_message. This can be plain text or HTML.
redirect_page_idConditionally required if type is page_redirect. Must be a valid, existing page ID.
redirect_urlConditionally required if type is url_redirect. Must be a valid absolute URL (https://sample.xyz/path-to-page) or relative path on the website (/path-to-page).
callbackConditionally required if type is trigger_callback. Must be a valid callback function, sanitized with the is_callableopen in new window PHP function to check for valid syntax.
Response Sample
{
    "type": "page_redirect",
    "redirect_page_id": 2
}

Reset Redirect

Reset the access denied redirect preferences.

Endpoint

DELETE /aam/v2/redirect/access-denied

curl --location --request DELETE 'https://example.xyz/wp-json/aam/v2/redirect/access-denied?access_level=role&role_id=subscriber' \
--header 'Authorization: Bearer ****'

Parameters

NameDescription
access_levelRequired. Can be either "role", "user", "visitor" or "default".
role_idConditionally required. The option is required if the access_level is "role".
user_idConditionally required. The option is required if the access_level is "user".
areaOptional. Specify "frontend", "backend" or "api". If omitted, settings for all areas will be reset.
Response Sample
{
    "success": true
}
Virtual Assistant