• Resolved Charles

    (@charlesrodmell)


    Hi. I’ve been using the Not Enrolled Redirect module with success. However, I just noticed that it’s not working any more. Various courses, all with redirects set, but they actually end up at /wp-admin/ (if not enrolled). I have tried this with all plugins disabled apart from LD 4.1.2 (I don’t want to upgrade yet) and Uncanny Toolkit 3.6.3. Both in staging and live. WP v6.0

Viewing 11 replies - 1 through 11 (of 11 total)
  • Thread Starter Charles

    (@charlesrodmell)

    P.S. I just tried updating my staging site to the latest LD and the issue is still present.

    Plugin Author Uncanny Owl

    (@uncannyowl)

    Hi @charlesrodmell , this probably isn’t good news for you, but on our side everything looks good and we haven’t seen other issues. I ran a test case on our side with the some configuration (well, WordPress 6.0.1) and everything works as expected.

    It’s the target of /wp-admin/ that seems especially odd, and not something we would do.

    You mean disabling other plugins. What about changing the theme and ruling out the child theme?

    And what about your redirect URL? Is it external to the site, is it valid, can you visit that page otherwise and not be redirected? What I mean there is that maybe your destination is adding its own redirect. It might be worth putting the URL through a tool like Redirect Detective to see if additional redirects are happening.

    Have any other changes happened on the site, like a migration, URL change, forcing SSL?

    It does unfortunately sound related to the configuration somehow.

    Thread Starter Charles

    (@charlesrodmell)

    Thanks for your ideas. The url is valid (external site) and works if I copy it from the uncanny settings and paste it into a browser (nothing in the detective). I tried the 2020 theme and the site has been ticking along as normal, with no changes elsewhere. So weird. Maybe the security plugin has left something in the .htaccess I’ll report back when I figure it out.

    • This reply was modified 2 years, 4 months ago by Charles.
    Thread Starter Charles

    (@charlesrodmell)

    Hi. I’ve made an entirely new test site on a new subdomain. Steps were:
    Create an A record on Cloudflare to point subdomain at server IP.
    Install letsencrypt SSL
    PHP7.4
    Install wp v6.0.1 and delete dolly / askimet plugins (no other plugins exist). Stay on default 2022 theme.
    Download and install / activate fresh plugin files for LD v4.2.1.2 (from learndash account area).
    Install and activate Uncanny toolkit via wp admin / plugins area.
    Turn on the “not enrolled redirect” module.
    Create a closed course with one lesson and enter a “not enrolled redirect” (I put https://google.com)
    Create a test user without access to the course, login and navigate them to the course url i.e. /courses/test
    I am then redirected to /wp-admin/ which is obviously unexpected!
    I then tried PHP8.1 but no change.
    My hosting is a VPS running Ubuntu 18.04.6 LTS, Apache/Nginx, MariaDB.
    I’m stumped… ??

    Plugin Author Uncanny Owl

    (@uncannyowl)

    Ah, now we understand it and why it’s happening.

    For security purposes, any URLs that are used in links go through wp_safe_redirect(); see https://developer.www.ads-software.com/reference/functions/wp_safe_redirect/. Presumably, whatever you’re linked to is not considered a safe URL by WordPress and is blocking it.

    For any URLs you want us to redirect to that aren’t local, you will need to register the domains to your WordPress site so it allows them. To do this, you can add the following code snippet sample to the bottom of your functions.php file:

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

    Let us know if you’re still having trouble after those changes.

    Thread Starter Charles

    (@charlesrodmell)

    Ok, superb. Thank you very much. That solved it.

    If anyone else reads this, please remove the final curved bracket to get the snippet to work, so:

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

    The reason it wasn’t working for me before this snippet is that I run Learndash on a subdomain and market the courses on the TLD.

    Hi! i install the code on function.php but unfortunately I have the exact same problem …

    Plugin Author Uncanny Owl

    (@uncannyowl)

    Hi @jacoposilvestri , maybe you can confirm the exact code you added and the specific behaviour you’re seeing. And what’s the redirect URL you’re using?

    Have you also confirmed that there’s no redirect on your target URL, and is it external?

    Hi! thanks for the support!

    here is the code i am using:

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

    I also confirm that there is no redirect.

    I also did the test with “www.google.it” and it always redirect me to / wp-admin.

    If instead I put inside the field without “https: //” or “www.” links to the url is chained, example:

    “www.website.it/website_redirect”`

    Plugin Author Uncanny Owl

    (@uncannyowl)

    Hi @jacoposilvestri , your issue sounds unrelated. The code snippet provided above is to allow redirects to external sites by whitelisting them since WordPress would normally block them. Google was just an example here, and it doesn’t control the redirect. In the example provided for the other user, it was just to whitelist that domain to allow WordPress URLs to point there.

    Yours sounds like an issue with the redirect target itself. Since this ticket is closed and marked as resolved, and probably not related to your issue, maybe you want to send us an email with more details. If you visit your URL directly as the user, does the link work without redirecting?

    I confirm that the current links inserted are not undergoing any redirects.

    and if I browse them they have no redirects

    I’ll send you an email with your login credentials too, so you can test yourself!

    However I don’t understand …

    I also need to redirect to external sites …

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Not Enrolled Redirect – stopped working’ is closed to new replies.