LearnDash – Restrict Posts or Pages for Students Enrolled in a Specific Course

In this tutorial, we show you how to restrict posts or pages for users who are enrolled in a specific LearnDash course.

For example, you can create a series or category of posts that will be used by users of a specific course and you do not want users to share the posts with anyone else. Only users enrolled in a course will have exclusive access to your posts or pages.

For this, we will use the WordPress Conditional Post Restrictions plugin.

This plugin allows you to apply conditional restrictions to your pages, posts, and any other custom post type such as courses, events, downloads, products, etc. With this plugin, you can manage your website content better and you can even create a subscription website.

To restrict posts or pages for users who are registered to a specific LearnDash course, you need to follow these simple steps:

1- Install the “WordPress Conditional Post Restrictions” plugin

You can download the plugin here:

Download WordPress Conditional Post Restrictions Plugin - or - Read more

This post assumes you alrady installed and activated the LearnDash plugin, as well as created the courses for which you want to restrict the posts or pages.

2- How to restrict individual posts for users enrolled on a specific course

First, we’ll see how to restrict a single post for users enrolled in a specific course.

  1. Go to Posts in wp-admin.
  2. Open a post that you want to restrict for users enrolled in a specific course.
  3. Scroll down to the Restriction rules section.

Here, you need to select the following values to restrict this post for users enrolled in a specific LearnDash course:

learndash restrict posts or pages to students enrolled in a course

  • Enable conditional restrictions: Yes
  • What happens when the conditions are met: Allow access
  • Condition 1: User is enrolled to course = WordPress course
  • Update the post to save the changes.

This is how you can restrict individual posts for students enrolled in a specific course.

Important

  • You decide which course(s) you want to use to restrict your posts.
  • To restrict other posts using the same condition, simply repeat the steps in each post.
  • If you want to use several courses as required to access your posts, add an “Or” condition or an “And” condition.
  • Or” means users can be in any of the selected courses.
  • And” means users must be in all the selected courses.

3- How to restrict an entire posts category for users enrolled in a specific course

If you have created an entire category of posts that you want to restrict for users enrolled in a specific course, you can restrict that category, so you don’t have to edit the courses individually.

  1. Go to Posts > Categories.
  2. Open the category you want to edit.

Once you open the category you’ll restrict, select the following values:

learndash restrict posts or pages to students enrolled in a course

  • 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 = WordPress Course
  • Update the category to save the changes.

Important

  • You decide which course(s) you want to use to restrict your posts.
  • If you want to use several courses as required to access your posts, add an “Or” condition or an “And” condition.
  • Or” means users can be in any of the selected courses.
  • And” means users must be in all the selected courses.

4- How to restrict pages for users enrolled in a specific course

To restrict pages for users enrolled in a specific course:

  1. Go to Pages in wp-admin.
  2. Open the page you want to restrict.

After opening the page you’ll restrict, you need to scroll down to the Restriction rules section and select the following values:

learndash restrict posts or pages to students enrolled in a course

  • Enable conditional restrictions: Yes
  • What happens when the conditions are met: Allow access
  • Condition 1: User is enrolled to course = WordPress course
  • Update the page to save the changes.

This is how you can restrict individual pages for students enrolled in a specific course.

Important

  • You decide which course(s) you want to use to restrict your pages.
  • To restrict other pages using the same condition, simply repeat the steps on each page.
  • If you want to use several courses as required to access your pages, add an “Or” condition or an “And” condition.
  • Or” means users can be in any of the selected courses.
  • And” means users must be in all the selected courses.

5- What happens when users try to access restricted posts or pages?

To select what happens when users try to access restricted posts or pages, you need to edit the global settings of the plugin.

Go to Settings > Post restrictions and you’ll see these fields and options:

  • Enable restrictions: Tick/untick this checkbox to enable/disable the global conditions.
  • Don’t apply restrictions for these user roles: You’ll see a list of user roles for which the conditions won’t be applied. By default, we will not apply restrictions for administrators, editors, and any user with the capability edit_others_posts.
  • What happens when the post is restricted? You have several options to select what happens when the post is restricted:
    • Redirect to URL
    • Remove the content and show a message
    • Show fragment of the content and show message after fragment
  • What happens when a category is restricted? You have several options to select what happens when the post 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

Restricting your posts for users enrolled in a specific course is really simple!

You can write entire categories of posts for your students of a specific LearnDash course. Teachers can write posts instead of eBooks or other types of content to reinforce the lessons or to give written instructions.

With WordPress Conditional Post Restrictions, you can apply this and any other conditional restrictions to your posts; this way, you have endless possibilities to manage your posts.

You can download the plugin here:

Download WordPress Conditional Post Restrictions Plugin - or - Read more