Exciting news! We're joining GoDaddy ➡️

Memberships makes it easy to restrict site content to members and to drip content based on how long someone has been a member. However, sometimes you may want to temporarily give early access to content to members, only making that content publicly available to non-members after some amount of time has passed.

There are any number of cases where that style of a content rollout could be valuable. A publisher with free and paid content might want to make the free content “members only” at first. A company that holds webinars could restrict speaker slides to members first. You might even want “early content access” to be a perk of membership that you use as a selling point. 

In this article, we’ll walk through how to provide your members with early access to content, then automatically open it up to non-members after a certain amount of time.

Create an “early access” category

First, we’ll create a category for the posts and/or pages we want to temporarily restrict. 

In this example, I’m calling the category Early Access. You can call this whatever you’d like, but keep an eye on the slug field here—we’ll need that later! (In this case, it’s early-access.)

How to create an early access category.

Now we can apply the category to a post or page that we want to restrict to members only. Don’t worry, we’ll set up a way to automatically remove this category later when we’re ready for non-members to see this.

Adding our early access category to a post.

Grant access with your membership plan(s)

Next, we’ll need to restrict our Early Access category so it’s only accessible to our members. Here, I’ve created an Early Access Member plan and restricted our Early Access category to members of this plan. However, you don’t need to create a new membership plan specifically for early access to content (unless that fits your business model). You can give early access to members on any or all of your existing plans.

Granting members access to our early access category.

With this plan saved, our post is non hidden from non-members. The message below can be adjusted in the WooCommerce Memberships settings so you can give non-members an idea of when the post will be available if they visit its page:

What non-members will see on restricted content.

Remove access restrictions on a schedule

With members and non-members now seeing exactly what they are supposed to see, it’s time to add the bit of magic that removes the Early Access category from our posts—and, as a result, opens it up to non-members.

Note: You’ll need to make sure that you know how to add PHP to your site to do this. You could add this snippet to your custom child theme, create your own custom plugin, or use a plugin like Code Snippets to add your code.

<?php // only copy this line if needed
/**
 * Remove 'early access' category from post after time to allow access for all
 */

// schedule category removal
function sv_wc_memberships_schedule_early_access_check( $post_id ) {

wp_schedule_single_event( strtotime('+1 week', time() ), 'sv_wc_memberships_check_post', array( $post_id ) );

}
add_action( 'publish_post', sv_wc_memberships_schedule_early_access_check );

// remove 'early access' category
function sv_wc_memberships_remove_post_cat( $post_id ) {

wp_remove_object_terms( $post_id, 'early-access', 'category' );

}
add_action( 'sv_wc_memberships_check_post', sv_wc_memberships_remove_post_cat, 10, 1 );

The sv_wc_memberships_schedule_early_access_check function schedules the category removal event to run one week after the post is published. You can change +1 week to adjust the length of time to allow the members-only access. For example, you could change this to +3 days or +24 hours, depending on how long your non-members should wait for your exclusive content.

The sv_wc_memberships_remove_post_cat function removes the category, which makes the content available to everyone. If you’ve chosen a different name for your category, you’ll need to replace early-access with your category’s slug.

That’s all there is to it! Now you can easily give members early access to your content, then automatically lift that restriction after a set period of time to grant access to non-members. 

Published by Marcus Burnette

Marcus is a Customer Support Specialist on the WooCommerce team, based out of Florida. When not at his desk, he can be found camping, hiking, or traveling - basically, any excuse to put his photography passion into practice!

2 Comments

  1. It would be great if you could also show the way how it works the other way around.So that the content could be seen first by all visitors and later (e.g. after 7 days) only by members.

    Reply
    • Hey Stephan! This is a neat idea — we typically see folks publish content publicly, and then after 7 days, add the content to membership plan rules to restrict it. I could see if you publish a huge volume of content, though, where that would get much harder to do. We’ll add that to our blog post list to take a look at 🙂

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *