9 comments on “Redirect A Woocommerce User After Login

  1. Hey there!

    This is a great help.

    I have a question though, what would you put after “$redirect_to =” if you want to send the user back to the page they were viewing before clicking login?

    I cant find an answer anywhere on the net!

    Thanks so much!

  2. Hi Phil,
    I have a question, if admin login, how redirect to dashboard? And if other user login, how redirect to account-page or other page?

    1. Personally, I would wrap the function around a basic check for user roles. Something like this:

      if ( current_user_can('manage_options') ) {
      redirect here
      } else {
      redirect here instead

  3. Phil,

    I am building a membership website that is using Groups and Woocommerce Groups to allocate pages based on purchases. What I’d like to do is change the customer login redirect so they go to the one of the pages they have bought. There is an added complication in that they can buy a first level of access that open up a dozen pages to them but then they can buy access to a second level of access, so if they buy level one I want to redirect them to page A from pages a, b and c but when they buy level two of access, and can now see pages a, b and x, y, z, I will need to redirect them to page X.

    Do you think that is do-able?

    1. Hi Paul,

      While I’ve never actually used the Groups extension for WooCommerce, it should still be possible.
      Looking at the plugin page on WooCommerce, each level of membership is allocated an ID, so in theory, you could add a conditional statement to the code above which allows you to check which ID level the user is on and redirect to X page (Page X will have ID X etc)

      It all depends on how the extension checks the user level against the ID but I think it could be done. Have you tried contacting the plugin developers? I’m sure it’s something they will be able to help with.

  4. Hi Phil,
    Just wondering if you could help.
    I have these functions working but wanted to know if it was possible in Woo to redirect a new user to a different page on FIRST login?
    So I can have a welcome new user and welcome back page. Other wise I will have to combine the two pages in a more generic welcome.

  5. Hi
    Thanks for your explanation above. I want to know how to redirect a user to a online appointment scheduling page which should only be visible when the use is logged in.

    Appreciate any help.Thanks

    1. Hi Anu,

      All the code on this page is aimed at redirecting a user once they have logged in, so the original code above will work, you just need to edit the page they are taken to after logging in:

      add_filter('woocommerce_login_redirect', 'pro_login_redirect');
      function pro_login_redirect( $redirect_to ) {
      $redirect_to = 'http://yourwebsite.com/appointments';
      return $redirect_to;

      I guess you just need to apply some code or membership plugin to make that page only accessible to members, so users who are NOT signed in see some message.

Leave a Reply

Your email address will not be published. Required fields are marked *