Visitor

Overview

The visitor level represents an unauthenticated request. It inherits from default and has no WordPress user or role.

Methods

Use AAM::api()->visitor(), guest(), or anonymous(); the matching service strings are visitor, guest, and anonymous. AAM::api()->user(0) also selects visitor. Omitting a service’s access level selects visitor only when the request is unauthenticated, so pass it explicitly when setting public rules from an admin request. get_id() returns null, and get_parent() normally returns default. Shared methods are in the access-level reference.

Example

$visitor = AAM::api()->visitor();
$visitor->posts()->deny(34, 'read');
// Equivalent: AAM::api()->posts('visitor')->deny(34, 'read');

$blocked = $visitor->posts()->is_restricted(34);

The rule applies to people who are not signed in. $blocked checks whether visitor access to post 34 is restricted.

Developer notes