Not Enrolled Redirect

Overview

Send visitors who aren’t enrolled in a course to a sales page, landing page, or sign-up form instead of leaving them on a blank or restricted course screen. The Not Enrolled Redirect module turns “you can’t access this” into a chance to convert.

What It Does

When a user tries to view a course they aren’t enrolled in, this module redirects them to a URL you choose. It applies to:

  • Logged-out visitors
  • Logged-in users who are not enrolled in that course

Administrators are excluded, so you can always preview the course yourself. Users enrolled through a LearnDash group are also treated as enrolled and are not redirected.

You set a separate redirect URL for each course, which lets you point every course at its own sales or landing page. The redirect applies to the course page itself, not to individual lessons or topics within the course.

Important: The redirect only fires for visitors LearnDash considers not enrolled. Because Open courses grant access to everyone, LearnDash never reports those visitors as “not enrolled,” so the redirect won’t fire on them.)

Before You Start

This module is part of the free Uncanny Toolkit for LearnDash and works with LearnDash 3.x.

  1. Go to WordPress Admin > Uncanny Toolkit.
  2. Enable the Not Enrolled Redirect module.

The per-course redirect field only appears after the module is active.

How to Set Up a Redirect

  1. Open the course you want to protect and go to Edit Course.
  2. Open the Settings tab (the Display and Content Options settings).
  3. Confirm the course Access Mode is set to Closed.
  4. Locate the Not enrolled Redirect URL field and enter the full URL where non-enrolled users should be sent (for example, your sales page).
  5. Update the course to save your changes.

[Screenshot: LearnDash Edit Course screen, Settings tab, with the “Not enrolled Redirect URL” field filled in and Access Mode set to Closed]

The redirect URL field supports shortcodes, so you can build dynamic destinations if needed.

Redirecting to Another Domain

By default, WordPress only allows redirects to URLs on your own site. If you want to send users to an external domain, you need to add that domain to WordPress’s list of allowed redirect hosts using the allowed_redirect_hosts filter.

Add the following to your child theme’s functions.php file, replacing example.com with the domain you’re redirecting to:

add_filter( 'allowed_redirect_hosts', 'uo_allowed_domains_list' );
function uo_allowed_domains_list( $hosts ) {
    $hosts[] = 'example.com';
    return $hosts;
}

We recommend adding code snippets through a child theme or a dedicated code-snippets plugin so your changes survive theme updates.

18 thoughts on “Not Enrolled Redirect”

    1. Good find! We’ll be releasing more info on this one shortly, but the URL settings are at the course edit level. So you can turn it on from the Toolkit screen, and that adds a field at the course level to enter the individual redirect behaviours at the course level. There is no way to set a global redirect; each course must have its own URL if you want to redirect them.

      1. Perhaps have a default setting to /my-courses and give the admin the flexibility to change it at the course level

        1. I’m afraid very few sites are likely to use that URL, so defaulting to what would very likely result in a lot of 404s and confusion. It’s much safer if we don’t include the default. Sorry about that!

  1. Would it be possible for you to add the redirect at the lesson level? When I apply the redirect at the course level, it does not allow users to take the sample lesson on my site.

    1. The most common use of this module is to prevent users from seeing the course page if they’re not enrolled, so if you’re offering sample content, we’d recommend not enabling it, but instead using the visitor and student shortcodes to show content on the course page depending on the user’s enrollment status.

  2. I’m having caching issues with this feature – it works at first to redirect to sales page. But when the sale is cplete and they have access to the course , I can’t stop the redirect from happening. Any fix for this?

    1. Typically, hosts don’t cache pages for logged-in users. Can you confirm that the users experiencing the redirect are in fact logged into the site when they try to visit the course page?

  3. hmmm, this doesn’t seem to be working for me as I can still access a lesson within the course when I’m not logged in. Is this only for the main course page? Or does it cover all the lessons/topics that roll up to a given course?
    https://prntscr.com/mau854

    I have Version 2.5 of the plugin.

    1. If you’re not logged in then the course must be Open, and if the course is Open then everyone is considered enrolled. This will not work for Open courses. Alternatively, it could mean the lesson is a Sample, which will also override the redirect behaviour. The module will only work properly with Closed courses.

  4. Hi,

    I have a translation question. When i translate the string: “Not enrolled Redirect URL”, it doesn’t work…
    Other translations i made to the uncanny plugin are working fine, but this one and “Redirect the user to the URL if they are not enrolled in the course” are giving me trouble.
    The only place where i can find these strings is in the uncanny plugin and not in learndash itself.
    Any ideas for a solution?

    Thanks in advance!

    1. Hi Tim, the strings you’re referring to are localized in the plugin the same way other strings are localized, so it’s not clear why you’re having trouble translating them. Those strings won’t appear in LearnDash; the fields are added by the Uncanny Toolkit, so you’d have to translate them in the Uncanny Toolkit plugin.

  5. Hi, I was unable to turn on this module. When I toggled it on, it wouldn’t stick, and upon refreshing the page, it would revert back to being off. I disabled all plugins except Learndash, and was able to toggle it on that way.

    However, I am now encountering a second issue. I’m using a test WordPress account and assigned my Learndash course to this test account, so this user has access to said course.

    The redirect is still on, but it is treating this test account as if it’s not enrolled in the course (even though it is) and I am being redirected when I shouldn’t be.

    I am now trying to turn off this module, but like turning it on, it will not stick. I disabled all plugins except Learndash and this time, it truly does not want to turn off.

    Have you encountered these issues before?

    1. Hi Mei, it sounds like a JS conflict that would be unique to your site, but you must log a ticket for us to be able to investigate and provide feedback; we can’t do it from Knowledge Base comments.

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top