• Resolved andyfreist

    (@andyfreist)


    Hi there, thanks for the awesome plugin ๐Ÿ™‚

    How can i set it up so that i have a set page redirect on login when visiting the normal login page without a referrer string, yet if they try to visit any other specific page, the referrer string works and it bypasses the normal redirect?

    Example of desired behavior (where “>” is a redirect):

    site.com/login > site.com/welcome
    site.com/page > site.com/login/?redirect_to=site.com%2Fpage > site.com/page

    I know how to get either one of these working, but how can I combine them? I’m still a php rookie, so any help would be greatly appreciated ๐Ÿ™‚

Viewing 1 replies (of 1 total)
  • Plugin Author Kevin Vess

    (@kevinvess)

    Hi โ€“ย Thanks for using Force Login, I’m glad you like it!

    I believe the answer your looking for is to use the same code I suggested on this topic:
    https://ww.wp.xz.cn/support/topic/redirect-to-dashboard-if-you-mistype/

    However โ€“ย you’ll want to change it slightly to meet your desired URL. For example:

    /**
     * Set the URL to redirect to on login.
     *
     * @return string URL to redirect to on login. Must be absolute.
     **/
    function my_login_redirect($redirect_to, $requested_redirect_to, $user) {
      if ( ! isset($_REQUEST['redirect_to']) ) {
        return home_url('/welcome');
      }
      else {
        return $redirect_to;
      }
    }
    add_filter('login_redirect', 'my_login_redirect', 10, 3);
Viewing 1 replies (of 1 total)

The topic ‘Conditional redirect’ is closed to new replies.