Role
Overview
A role level holds rules for one WordPress role. It normally inherits from default, and users assigned that role inherit its rules.
Methods
Use AAM::api()->role('editor') to obtain the level, or pass role:editor to a service such as posts('role:editor'). The value after role: is a registered WordPress role slug. A bare slug is not a service access-level value. get_id() returns that slug, get_display_name() returns its label, and get_parent() normally returns default. Shared methods are in the access-level reference.
Example
$role = AAM::api()->role('editor');
$role->posts()->deny(34, 'read');
// Equivalent: AAM::api()->posts('role:editor')->deny(34, 'read');
$slug = $role->get_id(); // editor
The editor role receives a read denial for post 34. get_id() returns the stable role slug, editor.
Developer notes
- The role slug must exist in WordPress; an unknown slug causes an error.
- Multi-role users may inherit this role alongside sibling roles when AAM multi-role support is enabled.
get_proxy_instance()exposes AAM’sWP_Roleproxy when you need core role details.