Viewing 8 replies - 1 through 8 (of 8 total)
  • Hi,

    not sure about 2, but I can help on issue 1.

    I believe the fix they suggest only works if you are using the login widget on your site. If it’s the login form directly you need to do something different.

    This how I did manage to redirect the user after woocommerce logged in.

    You just need to add an <input type=”hidden” name=”redirect” value=”<?php echo get_home_url(); ?>” /> to your login form and set the value attribute with the url you want to redirect to.

    Please make sure you are not editing the form-login.php file directly on woocommerce, if you need you can add a copy of this file on your theme directory (my-theme/woocommerce/myaccount/form-login.php) and do whatever you need to do here.

    Hope this is helpful.

    Thread Starter whitneyr

    (@whitneyr)

    Very helpful!
    This worked like a charm!

    Thread Starter whitneyr

    (@whitneyr)

    One more thing.
    I tried to do this in the same file for the registration.
    I want to forward to the home page after the customer registers for the first time. Instead it goes to the my acct page.

    Any idea on how to get this to work?

    Thank you!

    hi
    Is it important add this code to specific place?
    I did it in my copy of form-login.php (Karma theme) and it doesn`t seem to work for me.

    If you want it to work on the normal login form for woocommerce, you should change the filter hook to woocommerce_login_redirect and add a return statement containing the url variable.

    add_filter('woocommerce_login_redirect', 'ras_login_redirect');
    
    function ras_login_redirect( $redirect_to ) {
         $redirect_to = 'http://anypage.com';
         return $redirect_to;
    }

    All of this should of course go in your themes functions file.

    Hi, i tried adding at the bottom of templates/form-login.php in many ways the code you gave ( <input type=”hidden” name=”redirect” value=”<?php echo get_home_url(); ?>” /> ) but no result. Could someone please give the exact code for redirection to homepage? My site url is http://i-gen.gr/ if needed.
    I would appreciate any answer from anyone.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘WooCommerce Login Redirect’ is closed to new replies.