Limit number of posts user can create

Limit the number of posts that a user can create.

Users that have the ability to manage any type of content, are allowed to create unlimited number of post records. Under post records, we mean posts with specific post types (e.g. Posts, Pages, Media, Products, etc.). This policy limits the number of posts of the specific post type that a user can create.

The policy comes with three default values that can be adjusted to your specific needs:

  • threshold (default “5”) – number of post records that user is allowed to create;
  • postType (default “post”) – type of post records to limit;
  • publicOnly (default “true”) – status of post records that is taken in consideration. If “true” – then published only and if “false” then private only;

Note! If a user created a maximum allowed number of posts, the “Add New” button, and submenu item will no longer be available. However, if the user deletes any of the existing posts, this would put him back under the threshold and the user will be able to create a new post.

{
    "Version": "1.0.0",
    "Dependency": {
        "wordpress": ">=5.0.0",
        "advanced-access-manager": ">=6.2.1",
        "aam-enhanced-access-policy": {
            "Name": "AAM Enhanced Access Policy",
            "URL": "https://aamplugin.com/dw/aam-enhanced-access-policy.zip",
            "Version": ">=0.0.1",
            "GitHub": "https://github.com/aamplugin/aam-enhanced-access-policy"
        },
        "${CONST.AAM_PLUS_PACKAGE}": {
            "Name": "Plus Package",
            "Version": ">=5.0.0",
            "URL": "https://aamplugin.com/pricing/plus-package"
        }
    },
    "Statement": {
        "Effect": "deny",
        "Resource": "PostType:post:posts",
        "Action": "Create",
        "Condition": {
            "GreaterOrEquals": {
                "${CALLBACK.AAM\AddOn\EnhancedAccessPolicy\Author\Content::getPostCount}": "${POLICY_META.threshold}"
            }
        }
    },
    "Param": [
        {
            "Key": "EnhancedAccessPolicy:Author:Content:PostType",
            "Value": "${POLICY_META.postType}"
        },
        {
            "Key": "EnhancedAccessPolicy:Author:Content:PublicOnly",
            "Value": "(*bool)${POLICY_META.publicOnly}"
        }
    ]
}
POLICY ID
Copy this unique number and use it to install the policy on your website. To learn more how it works, follow this link.
DEPENDENCIES List of required plugins for this policy to work properly.
WordPress >=5.0.0
Advanced Access Manager >=6.2.1
AAM Enhanced Access Policy >=0.0.1
Plus Package >=5.0.0
ASSIGNEES The type of audience the policy is automatically applied to as well as excluded. To learn more how it works, follow this link

This policy does not apply to any role, user or visitors. You need to attach this policy to desired audience manually. Learn more here.