Abilities
Overview
Allow or deny registered WordPress abilities. Select the subject with AAM::api()->abilities($access_level, $settings). Omit $access_level to use the current user or visitor.
PHP class: AAM_Framework_Service_Abilities.
Method reference
| Method | Purpose |
|---|---|
deny($name) |
Store a deny rule. |
allow($name) |
Store an allow rule. |
reset($name = null) |
Remove one rule or all rules for this level. |
is_denied($name) |
Check the effective deny decision. |
is_allowed($name) |
Check the effective allow decision. |
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 registered ability name as a string, for example 'my-plugin/manage-reports'. The same name goes to deny(), allow(), and the decision methods. This service does not accept an ability object or register the ability.
Example
$abilities = AAM::api()->abilities('role:subscriber');
$abilities->deny('my-plugin/export-data');
$blocked = $abilities->is_denied('my-plugin/export-data');
The first call saves a deny rule for the Subscriber role. $blocked checks that same ability for that role; it should be true after a successful write.
Developer notes
- The identifier is the registered ability name.
- Use this service when working with the WordPress Abilities API; it does not register abilities.
- The selected access level determines whose rules are stored or evaluated. See Access levels.
Behavior and parameters
deny($name)andallow($name)write a rule for a registered ability name.reset($name = null)clears one or all ability rules.is_denied()andis_allowed()resolve inherited access. Validate the ability name against WordPress registration.