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
- Use a path or full URL as the schema. A URL rule can carry an access-denied redirect configuration.
- The framework evaluates a rule; AAM runtime integrations enforce restrictions during WordPress requests.
- The selected access level determines whose rules are stored or evaluated. See Access levels.
Behavior and parameters
allow($schema)anddeny($schema, $redirect = null)accept one URL schema or an array of schemas. Use a path such as/members/*or a full URL.reset($schema = null)removes one rule or all URL rules for this access level.is_denied($url)andis_allowed($url)resolve the effective rule for a requested URL.get_redirect($url)returns the redirect attached to the matching denied rule, if one exists.- A denied rule may include an access-denied redirect model. For example,
['type' => 'custom_message', 'message' => 'Members only']. Without one, the access denied redirect preference applies. - Match paths and query strings deliberately. Test a URL with and without its query string when your rule includes query parameters.