Website Building » WooCommerce » How Do I Split the Login and Register Page in WooCommerce?

How Do I Split the Login and Register Page in WooCommerce?

Last updated on January 23, 2023 @ 3:55 pm

When it comes to WooCommerce, there are a few different ways that you can go about handling your login and register pages. You can either use the default WordPress pages for these purposes or you can create custom pages specifically for WooCommerce.

If you’re using the default WordPress pages, then you can simply add the [woocommerce_login] and [woocommerce_register] shortcodes to those pages. However, if you want to split the login and register page in WooCommerce, then you’ll need to take a few additional steps.

First, you’ll need to create two separate pages for your login and register forms. You can title these pages whatever you like, but something like “Login” and “Register” would be appropriate. Once you have those pages created, you’ll need to add the following code to your functions.php file:

<?php add_action( 'init', 'split_login_register' );
function split_login_register() 
{ if ( isset( $_GET['action'] ) && 'register' == $_GET['action'] ) 
{ wp_redirect( home_url( '/register/' ) );exit; }} 

This code will redirect any users who try to access the WordPress registration page to your custom registration page. Next, you'll need to add the following code to your theme's header.php file:

PRO TIP: If you are using WooCommerce to create an online store, it is important to note that you should not split the login and register page. Doing so can create confusion for your customers and may result in lost sales.

<?php if ( ! is_user_logged_in() ) { ?>
<ul class="nav navbar-nav navbar-right">  
<li><a href="" title="Login">Login</a></li>  
<li><a href="<?php echo esc_url( home_url( '/register/' ) ); ?>" title="Register">Register</a></li>  
</ul><!--/.nav-collapse -->
<?php } else { ?>
<ul class="nav navbar-nav navbar-right">  
<li><a href="<?php echo esc_url( home_url( '/logout/' ) ); ?>" title="Logout">Logout</a></li></ul><!--/.nav-collapse --><?php }?>
Dale Leydon

Dale Leydon

Sysadmin turned Javascript developer. Owner of 20+ apps graveyard, and a couple of successful ones.