User
Overview
A user level holds rules for one WordPress account. It inherits from the user’s primary valid role, then default. If there is no valid role, it inherits directly from default.
Methods
Use AAM::api()->user(42), user('name@example.com'), user('login'), or user(new WP_User(42)). The service string takes user: followed by an ID, login, or email, for example urls('user:42'). A raw WP_User must first be wrapped with AAM::api()->user($wp_user) before it can be passed as a service access level. With no argument, user() returns the current user or visitor; user(0) selects visitor. get_id() returns the WordPress user ID. Shared methods are in the access-level reference.
Example
$user = AAM::api()->user(42);
$user->urls()->deny('/account/export/');
// Equivalent: AAM::api()->urls('user:42')->deny('/account/export/');
if ($user->urls()->is_denied('/account/export/')) {
// Handle the decision in a custom flow.
}
The rule applies to user 42. is_denied() checks the URL decision for that same user; a custom flow must act on the result.
Developer notes
- Resolve a real user before writing a user-specific rule. An unknown identifier causes an error.
- With AAM multi-role support, other valid user roles become siblings of the primary role and their permissions are merged.
get_proxy_instance()exposes AAM’sWP_Userproxy. Useget_id()for the stable numeric identifier.