How to sell access to a protected area of your site
Our Password Protected Categories plugin lets you lock down specific categories of WordPress pages, posts, or any custom post type. Only authorized users can access them. Most of our customers manually give their users the logins to their protected categories. This article will tell you how to automate this process.
You'll learn how to sell access to protected WordPress categories and automatically give purchasers their logins for the hidden content. For example, you might want to do this if you are creating a WordPress membership site where people can buy access to a members-only shop containing exclusive products.
We'll do this using WooCommerce to sell access to the protected area; and Password Protected Categories to create the protected area. Before you start, you should install the free WooCommerce plugin on your WordPress site.
Step 1 - Create a new user role
Create a dedicated user role with the free User Role Editor plugin. Do this by cloning the 'Customer' role that comes with WooCommerce itself. For example, if you are selling access to a hidden members area then you might create a new role called 'Members'.
When you create the new user role, you should edit the privileges for this role to give it access to private content. You will see an alphabetical list of all the WordPress user role capabilities. Scroll down to the ‘R’ section and tick the following boxes. (Depending on your plugins, you may not see all these boxes, and there may be similar ones that you need to tick too. Don’t worry about this – just tick the boxes that apply to your site):
- Read private pages
- Read private posts
- Read private products
Step 2 - Create a hidden area on your website
Use Password Protected Categories to create a category of posts, pages, or any custom post type. This category will contain the information that will be hidden from public view. Protect this category by marking it as 'Private'.
To create more complex members-only shops, add multiple categories and mark them all as 'Private'.
Step 3 - Create a product that gives access to the hidden area
Next, go to Products → Add New. Create a WooCommerce product which people will purchase to gain access to the private area you created in Step 2. DO NOT put this product in a private category, as it should be available for anyone to view.
Step 4 - Give access to people who purchase the product
In the main WooCommerce settings (WooCommerce → Settings), you should disable guest checkout. If you do this, then WooCommerce will automatically create a user account for everyone who makes a purchase. WordPress will also send them their login details so they can access the hidden area.
Use YITH's Automatic Role Changer plugin to automatically change the role of everyone who purchases the product you created in Step 3. Set it up to automatically change the role from 'Customer' to 'Member' (or whatever you chose to call the new role), thus giving them access to all your private categories.
Step 5 (optional) - Create an email for everyone who buys the membership product
As you saw in Step 4, WordPress will email each customer their login details so that they can access the hidden members-only store. However, this email will be fairly basic and may not be as professional as you would like.
Instead, you can use the Follow-Ups plugin to create a custom email that is sent to everyone who buys the product you created in Step 3. This should contain useful information such as how to access the private members-only area.
Step 6 (optional) - Add your members area links to the menu
Once someone has purchased access to the hidden area of your site, you need to make it easy for them to find it.
You can easily do this by going to Appearance → Menus and adding links to your private categories to your website menu. The Password Protected Categories plugin will only show these links to logged in users with access to these categories. The links will be hidden from everyone else.
Note: To use this feature, you must untick the 'Show password protected categories and posts to visitors' box on the Password Protected Categories plugin settings page.
Can I expire people's access to the hidden area?
Yes, you can do this by using the free Expire Users plugin to automatically expire people's user logins - and therefore revoke their access to the private area - after a specific period has elapsed.