[BUSINESSBLOOMER] WooCommerce: Separate Login and Registration Pages (ok)
https://www.businessbloomer.com/woocommerce-separate-login-registration/
There are times when you need to send logged out customers to a Login page and unregistered customers to a distinct Register page.
As you know, the WooCommerce My Account page, which contains the [woocommerce_my_account] shortcode, has both Login and Registration forms when registration is enabled on the My Account settings.
This is not always a good idea, mostly when you use landing pages or sales pages with a specific goal e.g. user registration.
Clearly, when this happens, you don’t want to have a login form there as well. My solution provides two new shortcodes, one for the login form and one for the register form.
Please be aware that the Registration Page shortcode content is copied from WooCommerce template files – if WooCommerce releases an update or makes a change to these files, you may need to update the snippet as well.
What to do before using the shortcodes below…
As you know, the [woocommerce_my_account] shortcode is a very important one and must be kept on the WooCommerce My Account page at all costs. This means, you can’t get rid of it or delete the My Account page.
So, if you want to have a LOGIN + MY ACCOUNT page, and a separate REGISTRATION page, use this stack:
[wc_reg_form_bbloomer] on the Register Page – SNIPPET #1 BELOW
[woocommerce_my_account] on the My Account Page
add a registration redirection snippet, so that they go to the My Account page
If you want to have separate LOGIN, REGISTRATION and MY ACCOUNT pages then use this stack:
[wc_reg_form_bbloomer] on the Register Page – SNIPPET #1 BELOW
[wc_login_form_bbloomer] on the Login Page – SNIPPET #2 BELOW
[woocommerce_my_account ] on the My Account Page
add a registration redirection snippet, so that they go to the My Account page
In both cases, you need to disable “Allow customers to create an account on the “My account” page” checkbox on the “Accounts & Privacy” settings”:
PHP Snippet #1: Separate WooCommerce Customer Registration Form Shortcode
Place this shortcode [wc_reg_form_bbloomer] in a brand new WordPress page and the register form will magically appear.
PHP Snippet #2: Separate WooCommerce Login Form Shortcode
Please read the notes above – you might not need this shortcode at all and [woocommerce_my_account] may be sufficient to show the login form.
Otherwise, please add this shortcode [wc_login_form_bbloomer] to a brand new Login page.
Related posts:
Where to add this snippet?
You can place PHP snippets at the bottom of your child theme functions.php file (delete "?>" if you have it there). CSS, on the other hand, goes in your child theme style.css file. Make sure you know what you are doing when editing such files - if you need more guidance, please take a look at my free video tutorial "Where to Place WooCommerce Customization?"
Does this snippet (still) work?
Please let me know in the comments if everything worked as expected. I would be happy to revise the snippet if you report otherwise (please provide screenshots). I have tested this code with Storefront theme, the WooCommerce version listed above and a WordPress-friendly hosting on PHP 7.3.
If you think this code saved you time & money, feel free to join 14,000+ WooCommerce Weekly subscribers for blog post updates or 250+ Business Bloomer supporters for 365 days of WooCommerce benefits. Thank you in advance :)
Need Help with WooCommerce?
Check out these free video tutorials. You can learn how to customize WooCommerce without unnecessary plugins, how to properly configure the WooCommerce plugin settings and even how to master WooCommerce troubleshooting in case of a bug!
Last updated