WordPress.org

Support

Support » Plugins and Hacks » WooCommerce » [Resolved] [Plugin: WooCommerce – excelling eCommerce] Redirect on login

[Resolved] [Plugin: WooCommerce – excelling eCommerce] Redirect on login

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

    I needed to do exactly this. 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.

    Thank you,
    I was tring to redirect using an hidden input width value “redirect_to” instead of “redirect”…

    If anyone is also using the login widget, you have to change also the woocommerce core file: /woocommerce/widgets/widget-login.php
    changinge the get_permalink(woocommerce_get_page_id(‘myaccount’)) with the ID of the new page (PS: core changes are always to avoid if possible)

    Any idea on how to do the same when someone Registers for the first time? I’d like to redirect to the homepage instead of myaccount. I am not using the widget.

    Yes whitneyr, I also need this snippet.When someone register, I want to redirect them to form fields to save their address instantly. Do you manage to redirect register page to other pages? Thanks

    I just received the answer on another forum and it worked for me.
    I’m not sure exactly what you are trying to do.
    Note, your dashboard may be setup differently:

    Go to “WooCommerce \ Settings” then select tab “Pages” on row “My Account Page” you can select page you want to redirect after login/register.

    Does this work?

    Hey whitneyr, thanks for your quick reply. Yes it work. But what the client wants is after the registration process the customer is redirected instantly to form fields to input his/her address like billing or shipping address and save it.

    Normally, after registration the customers are redirected to My Account page and they have to click on Edit to save the addresses. This involves 3 step process to save the addresses and infos. My client wants 2 step process to save the address, Register>>then form fields.

    I’ll appreciate your response.

    Oh I see.
    Without really having a chance to think about it,
    my first thought is the get the url of the page where your enter the address.

    For me, I simply went to My Account and hovered over the edit button to find the address: http://domain.com/my-account/edit-address/?address=billing

    Of course yours will be different.

    Then, again this being my first thought, use the redirect code within the registration form found in form-login.php and replace the url with your ‘edit address url’.

    Here is the code as given by aaires (above):
    <input type="hidden" name="redirect" value="<?php echo get_home_url(); ?>" />

    change get_home_url() to the appropriate url.

    *NOTE, as aaires mentioned above, make sure you are not working on the core files.

    Also, as Riccardo mentioned above, you may need to follow his steps if you are using the login widget.

    I’ll keep thinking on this one. Let me know if this solution works.

    I can’t get this to work, cause I can’t find form-login.php file

    Can someone help me please?

    You can find the form-login.php in your theme folder:
    /wp-content/themes/YOUR-THEME/woocommerce/myaccount/form-login.php

    Or in your woocommerce folder:
    /wp-content/plugins/woocommerce/templates/myaccount/form-login.php

    PS: It’s always suggested to copy your woocommerce templates folder to your theme to avoiding overwriting on woocommerce versione update 😉

    Anyone know how to redirect specific roles to specific pages? I.E. dealers are redirected to a specific url upon login.

    Thanks in advance.

    Adding the hidden input ‘redirect’ approach works on the login form but not the registration form. However, you can now use a filter. See

    https://github.com/woothemes/woocommerce/commit/014e31952828377bf7a1ebf4e812a43d0bcefa67#commitcomment-3351995

    Hi, i tried the code you gave but i want to redirect user after login to homepage. What should be the exact code for that as there is no page id for homepage?
    Thanks.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘[Resolved] [Plugin: WooCommerce – excelling eCommerce] Redirect on login’ is closed to new replies.
Skip to toolbar