• Resolved Simon

    (@simonmaddox)


    Would it be possible to change the functionality of the plugin if a user goes to the new login url but is already logged in? Currently it sends all users to wp-admin, but this is not helpful for non administrators.

    I have hacked the code at line 447 in plugin.php to redirect to home if not admin and wondered whether this could be incorporated into the next release?

    if ( is_user_logged_in() && ! isset( $_REQUEST['action'] ) ) {
    	if(is_admin()) {
    		wp_safe_redirect( admin_url() );
    	} else {
    		wp_safe_redirect('/');
    	}
    	die();
    }
    
Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author NicolasKulka

    (@nicolaskulka)

    That is to say ? I did not understand the problem.

    Thread Starter Simon

    (@simonmaddox)

    Thanks for the quick response, Nicolas.

    The problem is that the plugin redirects to wp-admin if a user is already logged in when they go to the setup login page.

    My use case: my client has a subscription membership and each week sends out an email when updated content is available. In the email is a link to the login page, which works unless a member is still logged in, in which case it tries to redirect to wp-admin (which we block to those members).

    I think redirecting to the site’s home page makes more sense for non admin logged in users .

    Plugin Author NicolasKulka

    (@nicolaskulka)

    Unfortunately it is a choice on our part not to redirect to the homepage but to a 404

    Thread Starter Simon

    (@simonmaddox)

    I don’t think so. I’m interested in what happens when people go to the correct login page when already logged in, not people going to /wp-login.

    If you look at the code in the area I mentioned above, if the person is already logged in and enters the correct login url you currently redirect to admin_url(). My request is to keep that for admins, but redirect to home page for others.

    Plugin Author NicolasKulka

    (@nicolaskulka)

    Yes but now we have made the choice to redirect them to the error 404 page

    Thread Starter Simon

    (@simonmaddox)

    I can understand that 404 is appropriate for someone going to WP’s standard login page – I think that’s what people want – but not for going to the legitimate login page. That doesn’t make any sense – why would you flag that page as unavailable?

    Plugin Author NicolasKulka

    (@nicolaskulka)

    What page ?

    I refer to a 404 if we are not connected.

    If you access the configured page, /login by default it works.

    Can you give me the use cases please?

    Thread Starter Simon

    (@simonmaddox)

    Use Case:

    1. User receives email with link to /login in it and clicks link
    2. Browser opens, WP user cookie present from previous login (i.e. still logged in)
    3. Browser redirects user to wp-admin page

    My only point is that wp-admin is a reasonable redirect for administrators, but not for general users (e.g. members of the site). Adding the additional check I suggested in my first post would send non-admins to the home page if already logged in.

    Plugin Author NicolasKulka

    (@nicolaskulka)

    is_admin check if view theme or backoffice and not check user r?le.

    Thread Starter Simon

    (@simonmaddox)

    if logged in
    –if admin
    —-goto wp-admin
    –else
    —-goto home
    –fi
    fi

    • This reply was modified 7 years ago by Simon.
    • This reply was modified 7 years ago by Simon.
    Plugin Author NicolasKulka

    (@nicolaskulka)

    This fix will be in the next release that will be released soon.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Change redirect when already logged in’ is closed to new replies.