URLs

Overview

Store and resolve access rules for URL paths and patterns. Select the subject with AAM::api()->urls($access_level, $settings). Omit $access_level to use the current user or visitor.

PHP class: AAM_Framework_Service_Urls.

Method reference

Method Purpose
allow($url_schema) Store an allow rule.
deny($url_schema, $redirect = null) Store a deny rule.
reset($url_schema = null) Remove one rule or all rules for this level.
is_denied($url) Check the effective deny decision.
is_allowed($url) Check the effective allow decision.
get_redirect($url) Read the effective redirect.

Return values vary by method. Rule updates usually return bool; reads can return a value, null, or an array. Errors follow the service’s error_handling setting and may produce WP_Error.

Accepted identifiers

Pass a URL path or full URL string, for example '/members/' or 'https://example.com/members/'. allow() and deny() also accept an array of URL strings to write several rules in one call. Decision methods such as is_denied() take one URL at a time; reset() takes one schema or no argument.

Example

$urls = AAM::api()->urls('role:subscriber');
$urls->deny('/members/*');
if ($urls->is_denied('/members/report')) {
    // Show your own response in a custom flow.
}

This denies Subscriber access to paths under /members/. The check tests one matching URL; a custom handler must decide how to respond when it returns true.

Developer notes

Behavior and parameters