Reputation: 41
I want to seperate the login and registration page for woocommerce. (there is a different solution that I don't get to work here: Separate registration page in WooCommerce website)
I duplicated the form-login.php and renamed it to register.php In the register.php template I deleted the login-content.
I want to add a page to wordpress and add the register.php template with a SHORTCODE to that page. How do I do this??
Then I could add a Register Link to the Login Page with
<a href="<?php echo get_permalink(put the ID of the registerpage here) ?>"><?php _e( ' Register' ); ?></a>
and the new shortcode register page is loaded. mmmhhh...
what do I have to add to the duplicated login /now register.php, that it can be loaded to any page with a SHORTCODE? that would be interesting.
Thanks for helping out!Best wishes, Mika
Upvotes: 2
Views: 14087
Reputation: 1331
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>
// Separete 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' );
}
}
Upvotes: 0
Reputation: 4732
A more straightforward way to do this is to save the contents of the original form-login.php
as form-login-single.php
, and then replace the file form-login.php
with:
<?php
if( isset($_GET['action']) == 'register' ) {
wc_get_template( 'myaccount/form-register.php' );
} else {
wc_get_template( 'myaccount/form-login-single.php' );
}
This way you don't need to modify your functions.php
further, plus you don't run into any trouble with double-rendering of the register form that I got when using @Hassan-ALi's method.
Upvotes: 7