Support » Plugin: Sky Login Redirect » Doesn’t work – redirects to homepage

  • Resolved michoscopic

    (@michoscopic)


    I was previously using code in functions.php and it worked fine, but recently, not sure when, it stopped working. Then I switched to this plugin hoping it’d work but it doesn’t work either 🙁 When I login with Linkedin, it redirects to the homepage.

    Is it just me? Does this still work for everyone else?

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter michoscopic

    (@michoscopic)

    For reference, I was using code from the below, both don’t work anymore, not sure if this plugin is based on the same concept.

    https://www.isitwp.com/redirect-back-to-referring-page-after-login/

    if ( (isset($_GET[‘action’]) && $_GET[‘action’] != ‘logout’) || (isset($_POST[‘login_location’]) && !empty($_POST[‘login_location’])) ) {
    add_filter(‘login_redirect’, ‘my_login_redirect’, 10, 3);
    function my_login_redirect() {
    $location = $_SERVER[‘HTTP_REFERER’];
    wp_safe_redirect($location);
    exit();
    }
    }

    https://stackoverflow.com/questions/47486014/how-to-redirect-wordpress-user-to-previous-page-after-login

    // Function to redirect after login
    add_filter(‘login_redirect’, ‘redirect_previous_page’, 10, 1);
    function redirect_previous_page( $redirect_to ){
    global $user;
    $request = $_SERVER[“HTTP_REFERER”];
    if ( in_array( $user->roles[0], array( ‘administrator’) ) ) {
    return admin_url();
    } elseif ( in_array( $user->roles[0], array( ‘subscriber’) ) ) {
    return $request;
    }
    return $redirect_to;
    }

    Thread Starter michoscopic

    (@michoscopic)

    I’ve disabled both codes from functions.php and the site is just running on this plugin now. Appreciate if anyone can shed any light on this. Thank you in advance.

    Plugin Author Matt Biscay

    (@skyminds)

    Hi,

    The plugin uses a different code base than the ones you mentioned. The problem lays in the social login (such as LinkedIn): because you leave temporarily the site to log in to LinkedIn and then get forwarded to the site, it breaks the previous page (which is not on-site per se). As a result, because the plugin gets an empty value, it redirects in the last instance to the homepage.

    If you log in using the user/password combo, you should be directed to the article though.

    Thanks,
    Matt

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    @michoscopic Even a subscriber, please never ask anyone to log into your site. That’s not permitted and I have archived that reply.

    @skyminds If offered, please refrain. I’ve archived your reply too.

    Plugin Author Matt Biscay

    (@skyminds)

    Hi,

    @jdembowski: thanks for the heads-up.

    @michoscopic: I checked your page and it’s redirecting to the article, not the homepage.

    The logout link explicitly sets the homepage as the final redirection. It might be set by the member plugin you’re using.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Doesn’t work – redirects to homepage’ is closed to new replies.