Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPForms is funded, why it matters, and how you can support us.

Osama Tahir

Osama is a Senior Writer at WPForms. He specializes in taking WordPress plugins apart for testing and sharing his insights with the world. Learn More

The Best WordPress Drag and Drop Form Builder Plugin

Easy, Fast, and Secure. Join over 6 million website owners who trust WPForms.

Please enable JavaScript in your browser to complete this form.

16 comments on “How to Add Login and Registration Redirects in WordPress

  1. Redirecting /wp-login?action=register works great when using this code but how would I go about doing the same for the /login and /wp-login.php pages?

    I tried doing it with this code but I really have no idea what I’m doing. Basically just guessing here.

    // Redirect login Page
    function my_login_page_redirect()
    {
    global $pagenow;

    if ( ( strtolower($pagenow) == ‘wp-login.php’) && ( strtolower( $_GET[‘action’]) == ‘login’ ) ) {
    wp_redirect( home_url(‘/my-account’));
    }
    }

    add_filter( ‘init’, ‘my_login_page_redirect’ );

  2. Hi,
    Is it possible to redirect the user to a specific location based on the button he just clicked to register/login?
    That mean that each different button would be linked to a different register/login form, each redirecting to a specific address.
    Would that be possible?
    Thanks in advance

    1. Hi Sowx,

      I’m afraid I’m not 100% sure of your question but yes, you can link buttons on your website to different forms and then once those forms are submitted, have them redirect the user to a different URL. If you need any more information on redirecting a user upon submitting a form, please check out our guide!

      I hope this helps!

  3. Hi, the auto login and redirection works great but for some reason im not receiving the notification emails. ( users are not available in the entries section as well )
    and when i disable the auto login, it works again.

      1. Hi, thanks for the reply, the email notifications are working fine now, but the other problem still remains, the form is still not storing the entries for users, i’ve tested it many times, the auto login and redirection is working great, and the email notifications as well, but for some reason its not storing users entries in the form, kindly suggest what to do Thanks.

  4. Hey! I’m getting an error when I try to add this copied code to the “snippits” plugin detailed in the “how to paste code snippets into your functions.php file”.

    Code:

    // Redirect Registration Page
    function my_registration_page_redirect()
    {
    global $pagenow;

    if ( ( strtolower($pagenow) == ‘wp-login.php’) && ( strtolower( $_GET[‘action’]) == ‘register’ ) ) {
    wp_redirect( home_url(‘https://date.intro-social.com/new-user/’));
    }
    }

    add_filter( ‘init’, ‘my_registration_page_redirect’ );

    Error Message:

    Don’t Panic
    The code snippet you are trying to save produced a fatal error on line 6:

    syntax error, unexpected ‘;’
    The previous version of the snippet is unchanged, and the rest of this site should be functioning normally as before.

    Please use the back button in your browser to return to the previous page and try to fix the code error. If you prefer, you can close this page and discard the changes you just made. No changes will be made to this site.

    1. I found a workaround. By using a global redirect manager, I was able to redirect the login from wordpress to my wpform.

      1. Hey Tyler – Thanks for letting us know! Glad to know you were able to sort it out, please feel welcome to reach out to us for any other questions!

    2. Hey Tyler, We had a small glitch on the site for a short span of time, that inserted some special characters in the code. I assume you tested the code during that time.

      Code formatting is fixed now, could you please try that code again and it should work fine.

      Apologies for the inconvenience!

  5. I think you need to add “exit”, e.g.

    if ( wp_redirect( home_url(‘/registration’) ) ) {
    exit;
    }

    If not, a multisite site will still put up the wp-signup.php page.

    1. Hi George!

      Thanks for your feedback regarding this. I’ve noted it to our team and we’ll review your suggestion.

      We appreciate you taking the time to reach out to us with this 🙂

  6. after the user login, the HOME (the main page) is not accessible; in other words, it redirects to a profile page persistently

    all other subpages (like contact) is accessible, only the HOME is not, as I said after login

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

This form is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.