How to sell access to your document library
When you build a document library with Document Library Pro, you can use its access control features to restrict any or all of your documents so that only authorized users can access them. Most people manually give access to the library - for example, so that employees can view internal documents. However, there are use cases where you might want to sell access to a document library.
The following tutorial will use the following tools:
- WooCommerce to sell access to the protected area. Before you start, you should install the free "WooCommerce" plugin on your WordPress site.
- Document Library Pro to create the document library and restrict access to it. Before you start, you should install the plugin and add some documents - but don't worry about restricting access just yet.
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'.
Step 2 - Restrict the document library to the new user role
Use these instructions to restrict the document library so that only the role you created in Step 1 can access it. You can either do this globally if you wish to restrict the entire library, or by category or per-document.
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 document library.
Step 4 - Give access to people who purchase the product
Go to the main WooCommerce settings (WooCommerce → Settings) and disable guest checkout. This ensures that WooCommerce will automatically create a user account for everyone who makes a purchase. WordPress will also send them their login details so they can log into the document library.
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 the restricted documents.
Step 5 (optional) - Create an email for everyone who purchases access
As you saw in Step 4, WordPress will email each customer their login details so that they can access the document library. However, this email will be fairly basic and may not be as professional as you would like.
Instead, you can use the Automate Woo 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 documents.
Step 6 (optional) - Add your document library links to the menu
Once someone has purchased access to the restricted document library, 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 document library to your website menu. There are several ways to structure this:
- The easiest way is to simply add your main 'Document Library' page to the navigation menu. If you have globally restricted access to this then the link will only be shown to logged in users with the correct role.
- You can also add menu links to individual document library categories. Again, if you have restricted access to the categories then only people with the correct role will see the links.
Note: To use this feature, you must untick the 'Show protected documents' box in the Document Library Pro settings.
Can people subscribe for continued access?
Yes - we recommend the WooCommerce Subscriptions plugin for this.
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.