Skip to main content

PostType

Vasyl MartyniukLess than 1 minute

Note!

Available only with the premium Complete Package.

Syntax

PostType:<post-type-slug>:posts
PostType:<post-type-slug>:term:<ID|slug>:posts

The post-type-slug is a valid post type slug registered with the core WordPress register_post_typeopen in new window function.

Definition

The PostType resource has two ways of defining access controls to the posts as follows. It supports all the actions that the Post resource exactly the same way.

When there is a need to define the default access controls to all posts, then the PostType:<post-type-slug>:posts resource is the right choice for the job.

For example, the statement below restricts reading all pages for unauthenticated users.

{
    "Statement": {
        "Effect": "deny",
        "Resource": "PostType:page:posts",
        "Action": "Read",
        "Condition": {
            "Equals": {
                "(*bool)${USER.isAuthenticated}": false
            }
        }
    }
}

However, when you need to set access controls to any specific term within a post type, use the PostType:<post-type-slug>:term:<ID|slug>:posts resource. This way, access controls will propagate only to posts that belong to that term.

The example statement below denies managing posts in the "Science" category.

{
    "Statement": {
        "Effect": "deny",
        "Resource": "PostType:post:term:science:posts",
        "Action": [
            "Edit",
            "Publish",
            "Delete"
        ]
    }
}