How to set expiration date for any WordPress content

With Advanced Access Manager 5.6 or higher, you have the ability to grant access to your website content for a limited time frame. For example, you can allow your visitors, to see certain page only until next Monday or January 1st 2 pm. After the specified time, access automatically becomes restricted.

WordPress Temporary Post Access

As soon as you entered expiration criteria, AAM monitors access to selected post or group of posts in real time. No further monitoring on your end is required.

By default, when access expires, AAM will swap access settings and restrict access to selected post or group of posts by using READ option. So when user tries to access content that expired, he/she will be redirected based on the Access Denied Redirect rule.

This behavior can be changed with the help of Access Policy where you literally have no limit on how to define access strategy. So basically you need to create the policy Statement that becomes applicable right after access to your content expires.

For example, if you specified that the page “Christmas Sales Promotions” (page’s permalink is christmas-sales-promotions-2019 or ID is 469) can be accessible by everybody until Dec 31th 2019 11:59 pm and after that time show message “Sorry, the Christmas Sales Promotions in no longer applicable”, then here is the policy that you can define:

{
    "Version": "1.0.0",
    "Dependency": {
        "wordpress": ">=5.2.1",
        "advanced-access-manager": ">=5.9.7"
    },
    "Statement": [
        {
            "Effect": "deny",
            "Resource": "Post:page:christmas-sales-promotions-2019",
            "Action": "Read",
            "Metadata": {
                "Teaser": {
                    "Value": "Sorry, the Christmas Sales Promotions in no longer applicable"
                }
            },
            "Condition": {
                "Greater": {
                    "${DATETIME.Y-m-d H:i:s}": "2019-12-31 23:59:59"
                }
            }
        }
    ]
}

Note! The same concept can be applied to any post, custom post type, category or custom term. You just have to specify the correct Resource depending on your needs.

Get notified about important updates and new features (no more than one email per month).