Not Enrolled Redirect

Overview

The Not Enrolled Redirect module adds a field to the Edit Course screen (in the Settings tab of the course in LearnDash 3.x) that enables you to specify a URL that users will be redirected to if they attempt to access the course but are not enrolled.  The redirect will apply to all logged-out users, as well as logged-in users that are not enrolled.  The redirect will not affect Administrator users.

This is particularly useful if you want to redirect non-enrolled users to a sales or purchase page rather than the standard course page which may not be optimized for course sales.

As of version 3.2.1, the Redirect URL field accepts shortcodes.

Important: If you are trying to redirect users to another domain/website, it’s important that your target domain be registered with your WordPress site as a safe destination. To do this, add the following snippet to the functions.php file of your child theme:

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

Replace “google.com” with your target domain.

18 replies
    • Ryan
      Ryan says:

      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.

      Reply
        • Ryan
          Ryan says:

          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!

          Reply
  1. Kevin Moore
    Kevin Moore says:

    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.

    Reply
    • Ken Young
      Ken Young says:

      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.

      Reply
  2. Johb
    Johb says:

    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?

    Reply
    • Ken Young
      Ken Young says:

      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?

      Reply
  3. M Waters
    M Waters says:

    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?
    http://prntscr.com/mau854

    I have Version 2.5 of the plugin.

    Reply
    • Ryan
      Ryan says:

      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.

      Reply
  4. Tim Menting
    Tim Menting says:

    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!

    Reply
    • Ken Young
      Ken Young says:

      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.

      Reply
  5. Mei
    Mei says:

    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?

    Reply
    • Ryan
      Ryan says:

      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.

      Reply

Comments/Questions

Please note that this is not a support forum. If you are experiencing issues on your site, please open a support ticket instead. Site-specific support questions submitted as comments will be unanswered.

Leave a Reply