WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
[resolved] Redirect on login (14 posts)

  1. Riccardo
    Member
    Posted 2 years ago #

    When I login I be redirected to user main page.

    Is it possible to change the page shown after login?

    http://wordpress.org/extend/plugins/woocommerce/

  2. Ana Aires
    Member
    Posted 2 years ago #

    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.

  3. Riccardo
    Member
    Posted 2 years ago #

    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)

  4. whitneyr
    Member
    Posted 2 years ago #

    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.

  5. moria2012
    Member
    Posted 2 years ago #

    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

  6. whitneyr
    Member
    Posted 2 years ago #

    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?

  7. moria2012
    Member
    Posted 2 years ago #

    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.

  8. whitneyr
    Member
    Posted 2 years ago #

    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.

  9. jagjeet_singh
    Member
    Posted 2 years ago #


  10. Kierew
    Member
    Posted 1 year ago #

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

    Can someone help me please?

  11. Riccardo
    Member
    Posted 1 year ago #

    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 ;)

  12. mike1394
    Member
    Posted 1 year ago #

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

    Thanks in advance.

  13. Scott Cropper
    Member
    Posted 1 year ago #

    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

  14. i-gen2013
    Member
    Posted 1 year ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic