Woocomerce - Seperate Registration Page

Hello,

Hello how could I create a separate registration page for customers in my website without a login form inside? I have created a new page x, I created a file page-x.php in my child theme and I dropped inside the following code I found at woocommerce / templates / myaccount / form-login.php

<div class="u-column2 col-2">

		<h2><?php _e( 'Register', 'woocommerce' ); ?></h2>

		<form method="post" class="register">

			<?php do_action( 'woocommerce_register_form_start' ); ?>

			<?php if ( 'no' === get_option( 'woocommerce_registration_generate_username' ) ) : ?>

				<p class="woocommerce-FormRow woocommerce-FormRow--wide form-row form-row-wide">
					<label for="reg_username"><?php _e( 'Username', 'woocommerce' ); ?> <span class="required">*</span></label>
					<input type="text" class="woocommerce-Input woocommerce-Input--text input-text" name="username" id="reg_username" value="<?php if ( ! empty( $_POST['username'] ) ) echo esc_attr( $_POST['username'] ); ?>" />
				</p>

			<?php endif; ?>

			<p class="woocommerce-FormRow woocommerce-FormRow--wide form-row form-row-wide">
				<label for="reg_email"><?php _e( 'Email address', 'woocommerce' ); ?> <span class="required">*</span></label>
				<input type="email" class="woocommerce-Input woocommerce-Input--text input-text" name="email" id="reg_email" value="<?php if ( ! empty( $_POST['email'] ) ) echo esc_attr( $_POST['email'] ); ?>" />
			</p>

			<?php if ( 'no' === get_option( 'woocommerce_registration_generate_password' ) ) : ?>

				<p class="woocommerce-FormRow woocommerce-FormRow--wide form-row form-row-wide">
					<label for="reg_password"><?php _e( 'Password', 'woocommerce' ); ?> <span class="required">*</span></label>
					<input type="password" class="woocommerce-Input woocommerce-Input--text input-text" name="password" id="reg_password" />
				</p>

			<?php endif; ?>

			<!-- Spam Trap -->
			<div style="<?php echo ( ( is_rtl() ) ? 'right' : 'left' ); ?>: -999em; position: absolute;"><label for="trap"><?php _e( 'Anti-spam', 'woocommerce' ); ?></label><input type="text" name="email_2" id="trap" tabindex="-1" /></div>

			<?php do_action( 'woocommerce_register_form' ); ?>
			<?php do_action( 'register_form' ); ?>

			<p class="woocomerce-FormRow form-row">
				<?php wp_nonce_field( 'woocommerce-register', 'woocommerce-register-nonce' ); ?>
				<input type="submit" class="woocommerce-Button button" name="register" value="<?php esc_attr_e( 'Register', 'woocommerce' );  ?>" />
			</p>

			<?php do_action( 'woocommerce_register_form_end' ); ?>

		</form>

	</div>

</div>
<?php endif; ?>

<?php do_action( 'woocommerce_after_customer_login_form' ); ?>

but it didn't work. What would you advise?

  • lesanis

    Hello Jude,

    I need to do that through woocomerce because users that will register through that form will be customers and they will have different account-profile and capabilities than the subscribers . How could I add login-form.php in a page-template? Something like

    <?php get_template_part( 'content', 'page', 'myaccount/login-form' ); ?>
    or
     woocommerce_get_template( 'myaccount/login-form.php' );

    Best Regards,
    lesanis

  • lesanis

    Hello again,

    I managed to resolve that!!

    1)Create a new blank page
    2) Create a file in your child theme with the name: page-(write here your new page's slug name without the parenthesis).php
    3) Copy your page.php template from your theme in this new file in your child theme.
    4) Disable from Woocommerce settings the option to have a registration form in "my account" page with the login form. Otherwise you will have 2 registration forms, one in my account page and one in your new page.
    5) Find in your new file in your child theme these lines propably before comments

    <?php while ( have_posts() ) : the_post(); ?>
    <?php get_template_part( 'content', 'page' ); ?>

    and drop the following code after the above lines

    <div class="registration-box">
    
    	<h2><?php _e( 'Register', 'woocommerce' ); ?></h2>
    
    		<form method="post" class="register">
    
    			<?php do_action( 'woocommerce_register_form_start' ); ?>
    
    			<?php if ( 'no' === get_option( 'woocommerce_registration_generate_username' ) ) : ?>
    
    				<p class="registration-row">
    					<label for="reg_username"><?php _e( 'Username', 'woocommerce' ); ?> <span class="required">*</span></label>
    					<input type="text" class="woocommerce-Input woocommerce-Input--text input-text" name="username" id="reg_username" value="<?php if ( ! empty( $_POST['username'] ) ) echo esc_attr( $_POST['username'] ); ?>" />
    				</p>
    
    			<?php endif; ?>
    
    			<p class="registration-row">
    				<label for="reg_email"><?php _e( 'Email address', 'woocommerce' ); ?> <span class="required">*</span></label>
    				<input type="email" class="woocommerce-Input woocommerce-Input--text input-text" name="email" id="reg_email" value="<?php if ( ! empty( $_POST['email'] ) ) echo esc_attr( $_POST['email'] ); ?>" />
    			</p>
    
    			<?php if ( 'no' === get_option( 'woocommerce_registration_generate_password' ) ) : ?>
    
    				<p class="registration-row">
    					<label for="reg_password"><?php _e( 'Password', 'woocommerce' ); ?> <span class="required">*</span></label>
    					<input type="password" class="woocommerce-Input woocommerce-Input--text input-text" name="password" id="reg_password" />
    				</p>
    
    			<?php endif; ?>
    
    			<!-- Spam Trap -->
    			<div style="<?php echo ( ( is_rtl() ) ? 'right' : 'left' ); ?>: -999em; position: absolute;"><label for="trap"><?php _e( 'Anti-spam', 'woocommerce' ); ?></label><input type="text" name="email_2" id="trap" tabindex="-1" /></div>
    
    			<?php do_action( 'woocommerce_register_form' ); ?>
    			<?php do_action( 'register_form' ); ?>
    
    			<p class="registration-row">
    				<?php wp_nonce_field( 'woocommerce-register', 'woocommerce-register-nonce' ); ?>
    				<input type="submit" class="woocommerce-Button button" name="register" value="<?php esc_attr_e( 'Register', 'woocommerce' );  ?>" />
    			</p>
    			<?php do_action( 'woocommerce_register_form_end' ); ?>
    
    		</form>
    			</div>

    Then style as you wish. I don't know why but woocommerce form's styling is not applied in a normal page so you have to style your form. Add in your child theme's style.css

    .registration-box{...your styling...}
    
    .register{.............}
    
    .page-id-(write here the number id of your new page without parenthesis)
    input[type="text"], input[type="email"], input[type="url"], input[type="password"], input[type="search"], textarea{...................}
    
    .page-id-(write here the number id of your new page without parenthesis) .registration-row button, html input[type="button"], input[type="reset"], input[type="submit"], .button, .button:visited{...............}

    That's it, enjoy your new registration page!!!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.