Title: Conditional redirect
Last modified: April 27, 2017

---

# Conditional redirect

 *  Resolved [andyfreist](https://wordpress.org/support/users/andyfreist/)
 * (@andyfreist)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/conditional-redirect-8/)
 * 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](https://wordpress.org/support/users/kevinvess/)
 * (@kevinvess)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/conditional-redirect-8/#post-9075931)
 * 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://wordpress.org/support/topic/redirect-to-dashboard-if-you-mistype/](https://wordpress.org/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.

 * ![](https://ps.w.org/wp-force-login/assets/icon.svg?rev=1904031)
 * [Force Login](https://wordpress.org/plugins/wp-force-login/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-force-login/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-force-login/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-force-login/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-force-login/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-force-login/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Kevin Vess](https://wordpress.org/support/users/kevinvess/)
 * Last activity: [9 years, 1 month ago](https://wordpress.org/support/topic/conditional-redirect-8/#post-9075931)
 * Status: resolved