Users
Overview
Manage access decisions about other WordPress users. Select the subject with AAM::api()->users($access_level, $settings). Omit $access_level to use the current user or visitor.
PHP class: AAM_Framework_Service_Users.
Method reference
| Method | Purpose |
|---|---|
deny($user_identifier, $permission) |
Store a deny rule. |
allow($user_identifier, $permission) |
Store an allow rule. |
is_denied_to($user_identifier, $permission) |
Check whether an action is denied. |
is_allowed_to($user_identifier, $permission) |
Check whether an action is allowed. |
reset($user_identifier = null) |
Remove one rule or all rules for this level. |
is_hidden($user_identifier) |
Check whether listing is hidden. |
hide($user_identifier) |
Deny listing. |
show($user_identifier) |
Allow listing. |
aggregate() |
Get effective permissions for this resource type. |
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 the target user as a numeric ID, numeric ID string, login, email address, WP_User, or AAM user proxy:
$target = 42; // Numeric user ID
$target = '42'; // Numeric ID string
$target = 'jane'; // Login
$target = 'jane@example.com'; // Email
$target = get_user_by('id', 42); // WP_User object
$target = AAM::api()->user(42)->get_proxy_instance(); // AAM user proxy
AAM::api()->users('role:editor')->hide($target);
Each assignment shows an alternative way to set $target; the final call uses the last form. These forms go to deny(), allow(), hide(), show(), reset(), and the decision methods. The argument to users() is the subject access level; it is separate from the target user.
Example
$users = AAM::api()->users('role:editor');
$users->hide(42);
$hidden = $users->is_hidden(42);
The service subject is the Editor role; user 42 is the target. hide() denies list_user, and $hidden checks whether that target should appear in user listings.
Developer notes
- The first argument identifies the target user, while the service access level identifies the subject.
hide()andshow()write thelist_userpermission.- A user decision can fall back to the target user’s role permissions when no direct rule exists.
- The selected access level determines whose rules are stored or evaluated. See Access levels.
Behavior and parameters
deny($target_user, $permission)andallow()accept one permission string or an array. Uselist_userfor visibility.reset($user = null)removes one target’s rules or all rules.aggregate()returns the effective permission map.is_denied_to()evaluates inherited role rules if the target user lacks a direct rule.