By default, all information and/or materials you add to the Materials tab in a LearnDash course is displayed to ALL visitors of your site, even those not enrolled in that course. But what if you want the materials to only be available to enrolled users?
LearnDash doesn’t offer a simple option, setting or checkbox to enable this, but you do have a few options. We’ll cover two common techniques you can use to protect your LearnDash materials.
Place Materials in Lessons Instead
One common solution is to place your materials in the first lesson of your course, instead of adding them to the course itself. Lessons are automatically protected by default, and only accessible to those who have access to the course. So an unenrolled user will never be able to see or access them.
You may want to create a new lesson that is dedicated to materials for the course, or you can include materials in multiple lessons throughout your course. It’s entirely up to you, and how your course is laid out.
Use the [student]
Shortcode
If you want to keep materials in the course (and not move them to a lesson), you can utilize the [student]
shortcode that LearnDash provides.
The [student]
shortcode actually has beginning and ending shortcodes, and all content placed between the beginning and ending shortcode will only be shown to enrolled users. Here’s a quick example:
[student]Only enrolled users can see this.[/student]
You can insert your course material just like you normally would, linking to a PDF, audio file, some other download, etc. Once you’ve added it to the materials section, simply add [student]
to the front of it and [/student]
at the end. Update your page and test it out.
When viewing the course page logged in as an admin, you should see the material. If you open the same course page in a private browsing window, or a different browser, not logged in, you will not see it.
The [visitor]
Shortcode
You can also combine this technique with the [visitor]
and [/visitor]
shortcodes. All content inside of these shortcodes will only be shown to unenrolled users. So you could say something like this:
[visitor]Materials are only available to enrolled students. Buy this course →[/visitor]
You can add a link to a product page or membership sign up to encourage visitors to purchase access to the course.
If you have any other tips for protecting LearnDash course materials, we’d love to hear about them over in the forum.