I use the WooCommerce plugin 2.0.13. On my account page there are login and register sections, both on the same page. I want them separate.
I edit form_login.php
to create two files: form_login.php
for login and form_register.php
for registration.
In the new form_login.php
I provide a link to form_registration.php
as follows:
<a href="' .get_permalink(woocommerce_get_page_id('myaccount')). '?action=register"> register </a>
In my theme's function.php
file, I added the following code.
/*// Separate login form and registration form */
add_action('woocommerce_before_my_account', 'load_registration_form', 2);
function load_registration_form() {
if (isset($_GET['action']) == 'register') {
woocommerce_get_template('myaccount/form-registration.php');
}
}
But this doesn’t work. What's going wrong? Is what I am doing completely wrong?
You can create a copy of the WooCommerce form-login.php
and name it form-register.php
. The form-login.php
is located in /woocommerce/templates/myaccount/
folder.
Then in the form-login.php
you can create a link to the form-register.php using this code:
<a href="' .get_permalink(woocommerce_get_page_id('myaccount')). '?action=register"> register </a>
Next you need to modify your themes function.php
file by adding the following code:
<?php
/* Separate login form and registration form */
add_action('woocommerce_before_customer_login_form', 'load_registration_form', 2);
function load_registration_form() {
if (isset($_GET['action']) == 'register') {
woocommerce_get_template('myaccount/form-registration.php');
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With