Post types

Overview

Manage inherited content access rules for an entire registered post type. Select the subject with AAM::api()->post_types($access_level, $settings). Omit $access_level to use the current user or visitor.

PHP class: AAM_Framework_Service_PostTypes.

The methods below require the premium add-on.

Method reference

Method Purpose
is_hidden_on($post_type, $website_area) Check whether listing is hidden in an area.
is_hidden($post_type) Check whether listing is hidden.
is_password_protected($post_type) Check for a password rule.
is_restricted($post_type) Check whether direct reading is restricted.
is_redirected($post_type) Check for a redirect rule.
is_teaser_message_set($post_type) Check for a teaser rule.
is_denied_to($post_type, $permission) Check whether an action is denied.
is_allowed_to($post_type, $permission) Check whether an action is allowed.
is_access_expired($post_type) Check whether a timed rule has expired.
set_password($post_type, $password, $exclude_authors = false) Set a password rule.
set_teaser_message($post_type, $message, $exclude_authors = false) Set a teaser message.
set_redirect($post_type, $redirect, $exclude_authors = false) Store a redirect model.
set_expiration($post_type, $timestamp, $exclude_authors = false) Set an expiration timestamp.
deny($post_type, $permission, $exclude_authors = null) Store a deny rule.
allow($post_type, $permission) Store an allow rule.
hide($post_type, $website_area = null, $exclude_authors = false) Deny listing.
show($post_type, $website_area = null) Allow listing.
get_password($post_type) Read the password rule.
get_teaser_message($post_type) Read the teaser message.
get_redirect($post_type) Read the effective redirect.
get_expiration($post_type) Read the expiration timestamp.
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 a registered post type slug string such as 'page' or a WP_Post_Type object from get_post_type_object('page'). The identifier selects the entire post type; use the posts service for one post.

Example

$types = AAM::api()->post_types('role:subscriber');
$types->deny('product', 'read');
$blocked = $types->is_restricted('product');

These premium methods deny direct reading for the product post type to Subscribers. $blocked checks the resulting post type rule.

Developer notes

Behavior and parameters