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

Behavior and parameters