In this tutorial, we’ll show you how to restrict ebooks or any other file to LearnDash course students.
This is really useful if you create ebooks in your WordPress site and want to give access to the users of a specific course only. This way, you’ll avoid your ebooks and files being downloaded by users who aren’t taking the course for which that eBook was created.
For this, you need a download manager for WordPress. We’re going to use the WordPress Download Manager plugin in this example. This is really important because you need your downloads to be a post type, and the WordPress Download Manager plugin does exactly that. It creates a post type called “Download” for WordPress.
Besides the WordPress Download Manager plugin, you need to use the WordPress Conditional Post Restrictions plugin, which allows you to add conditional restrictions to your posts, pages, events, courses, products, downloads, etc. Any custom post type can be restricted using any condition with this WordPress plugin.
You can download the plugin here:
Download WordPress Conditional Post Restrictions Plugin - or - Read more
After installing and activating the plugin, you need to follow these simple steps to restrict ebooks or any other file for users enrolled in a LearnDash course.
1- Open the file you’ll restrict to course students
Since we’re using the WordPress Download Manager plugin, we need to open the downloads list by going to Downloads > All files.
Once there, you’ll see the files you’ve created. We’ll edit the Understanding WooCommerce ebook and will make it available to the WooCommerce Course students only.
2- Restrict ebooks or files to course students only
Once you open the ebook or file you’ll restrict to a LearnDash course students only, you need to scroll down to the Restriction Rules section and select these values:
- Enable conditional restrictions: Yes
- What happens when the conditions are met: Allow access
- Condition 1: User is enrolled to course = WooCommerce course
- Update the file to save the changes.
This is how you can easily restrict ebooks of files to a specific course’s students only. Students of other courses won’t be allowed to download this ebook.
3- Restrict file categories to course students only
Course students not only get ebooks. There are courses that include ebooks, pictures, videos, software projects, templates, etc. In that case, it’s better to restrict entire file categories instead of restricting files one by one.
In WordPress Download Manager, we open the categories by going to Downloads > Categories. We’ll open and edit the category called “WooCommerce Course Files”. We’ll make it available to the WooCommerce Course students only.
Once you open the category, select the following value to restrict the files to course students only.
- Enable the conditional restrictions: Yes
- Apply restrictions to: Category and posts
- What happens when the conditions are met: Allow access
- Condition 1: User is enrolled to course = WooCommerce Course
- Update the category.
It’s really easy, and now your course files will be protected because only the students enrolled in this course will have access to the files.
5- What if a user tries to access a restricted file?
WordPress Conditional Post Restrictions allows you to select what happens if a user tries to access a restricted file.
Go to Settings > Post restrictions and you’ll see these fields and options:
- If the downloads are restricted, you can:
- Redirect to URL
- Remove the content and show a message
- Show fragment of the content and show message after fragment
- If the category is restricted
- Show error 404
- Show the normal page without posts
- Show an error message
- Redirect to another URL
- Show the content of another page
That’s really simple!
You can see that restricting ebooks and files to students enrolled in a specific LearnDash course is really simple! You don’t have to program anything nor spend great amounts of money. You can apply this and any other conditional restrictions to your posts, pages, courses, files, downloads, products, etc.
You can download the plugin here:
Download WordPress Conditional Post Restrictions Plugin - or - Read more