Home » WooCommerce: Separate Login and Registration Pages

WooCommerce: Separate Login and Registration Pages

by Tutor Aspire

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.

Give it a go, feedback is much appreciated 🙂

New shortcodes to display WooCommerce Login and Registration forms separately

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”:

Either way, you need to disable registrations from the “My Account” page

PHP Snippet #1: WooCommerce Customer Registration Shortcode

Place this shortcode [wc_reg_form_bbloomer] in a brand new WordPress page and the register form will magically appear.

/**
 * @snippet       WooCommerce User Registration Shortcode
 * @how-to        Get tutoraspire.com FREE
 * @author        Tutor Aspire
 * @compatible    WooCommerce 7
 * @donate $9     https://www.tutoraspire.com
 */
  
add_shortcode( 'wc_reg_form_bbloomer', 'tutoraspire_separate_registration_form' );
   
function tutoraspire_separate_registration_form() {
if ( is_admin() ) return;
if ( is_user_logged_in() ) return;
ob_start();

do_action( 'woocommerce_before_customer_login_form' );

   // NOTE: THE FOLLOWING 

IS COPIED FROM woocommercetemplatesmyaccountform-login.php
// IF WOOCOMMERCE RELEASES AN UPDATE TO THAT TEMPLATE, YOU MUST CHANGE THIS ACCORDINGLY

?>

>





You may also like