Guides to help you get started
This use case revolves around the idea of having a website where you will be selling a subscription to the users and allowing them to access certain content as long as their subscription is valid. The idea is that you can sell a WooCommerce subscription product which has, of course, limited validity and as long as the customer has their subscription active, they will be able to access the content of certain page or post. This is particularly interesting if you are, for example, selling some kind of online courses but you don’t want your customers to be able to access a particular course (or whatever other content) indefinitely but rather to have an “expiration date” or to require them to renew their subscription in order to have continual access to the content of certain page or post.
First of all, make sure that you have installed and activated all three required plugins: Restrict (premium version is required), WooCommerce and WooCommerce Subscriptions. Of course, you will also have to enable and configure at least one payment gateway for WooCommerce.
Head to WooCommerce Settings -> Subscriptions tab and make sure that Subscriber Default Role and Inactive Subscriber Role have different roles selected. For example, if your default subscriber role is set to Subscriber, then your inactive subscriber role should be set as Customer (or any other you see fit but different than subscriber default role).
We will get back later to the details of why this is required but for now just make sure that you made this change.
Go on now and create a WooCommerce subscription product. In the example screenshot below, we have created a simple subscription product priced at $10 and which requires a monthly renewal.
Of course, if your scenario has multiple different pricings, you can also create multiple simple subscription products or even a variable subscription product and then use product variations to present different options that you’re offering. But, for the sake of simplicity of this solution, we will stick to the single simple subscription product.
When you’re done creating your subscription product (or products), head to Restrict -> Shortcodes and then scroll all the way down to the WooCommerce Users area. Within this area, you should select a Specific Product option and then select the product (or multiple products) that will be required for customers to purchase in order to view the content on some of your pages or posts. In the example below, we have selected a product titled My Online Course (this is the subscription product we have created in the previous step) which means that customers will need to purchase this product in order to access our content.
When you’re done making your selection, simply click the Copy button to copy the auto-generated shortcode.
This is where things are finally coming together as we will now finally create a page or post which we will be using to display the content. So, go on and create a page or post for this. In our example, we will create a post and then paste the shortcode we have copied in the previous step to the content area:
Now, to make it easier to understand the shortcode part, we divided it to three parts: first part that says [rsc_restrict_content allowed_to=”woo” woo_options=”product” woo_product=”95″] is the “opening” part of the shortcode which is followed by the actual content (the part where it says Your content here) and finally the “closing” part of the shortcode [/rsc_restrict_content]. So, whichever content you want to restrict should be in between the opening and closing part, right where the Your content here is currently placed. With the shortcode, set up like this you will be actually limiting access to the content within the “opening” and “closing” parts of the shortcode only to the customers who purchased a specific WooCommerce product which is defined by the shortcode. BUT, this is only the first part of the story with the second one being even more interesting 🙂
So, below the content area, you will notice Restrict’s menu Content Available To which we will also use for this scenario. In this menu, you should select Users with specific role and then select a user role below that should match the user role that you have selected in WooCommerce Subscription settings as Subscriber Default Role. In our case that will be Subscriber.
With this, you will be actually limiting the access to the whole content above only to the users with the Subscriber user role.
After that, you’re basically done.
And now, for the explanation…
So, we have actually created here two different criteria for accessing the content on the page or post. And in order for the user to access the content, they must meet both of these criteria. If, for example, we went on and just limited access to the content to the customers who purchased a specific WooCommerce product, that would work but with one major drawback: they would be able to access the content even when their subscription expired which misses the end goal of this scenario. On the other hand, if we only limited access to the content to users with specific user role, then the content would be available to all the users who purchased any WooCommerce subscription product (and therefore gained the Subscriber user role) which also misses the end goal. Because of this, we have employed here two different criteria which allow you to limit the access to the content to users who purchased a specific WooCommerce (via Restrict’s shortcode) but if their subscription expires and therefore their user role changes (as we have set up at the very beginning), they won’t be able to access the content.
Although this solution requires a premium version of Restrict (for the shortcodes) and WooCommerce Subscriptions add-on which is not free, and requires a bit of tweaking, with this combination you can have quite powerful subscription-based content restriction system on your website suitable for various scenarios.