WordPress.org

Forums

[resolved] WooCommerce Login Redirect (6 posts)

  1. whitneyr
    Member
    Posted 9 months ago #

    FYI: I have done extensive research on this topic.

    I have a members only site running woo commerce.

    1. I would like users to be redirected to the home page (http://mydomain.com) after login and registration. Currently users are directed to their account page.

    The woocommerce site lists the following fix. However, I've had no luck with it.

    /*
     * goes in theme functions.php or a custom plugin
     *
     * By default login goes to my account
     **/
    add_filter('woocommerce_login_widget_redirect', 'custom_login_redirect');
    
    function custom_login_redirect( $redirect_to ) {
         $redirect_to = 'http://anypage.com';
    }

    2. Is there a way to moderate Registration. Meaning if a user registers, they are held in a queue until I can approve them.

    Thank you kindly.

  2. aaires
    Member
    Posted 9 months ago #

    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.

  3. whitneyr
    Member
    Posted 9 months ago #

    Very helpful!
    This worked like a charm!

  4. whitneyr
    Member
    Posted 8 months ago #

    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!

  5. iwona
    Member
    Posted 3 months ago #

    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.

  6. Scott
    Member
    Posted 2 weeks ago #

Reply

You must log in to post.

About this Topic