How Tdo New Customers Register Woocommerce
There are times when you demand to send logged out customers to a Login page and unregistered customers to a distinct Annals page.
Equally you know, the WooCommerce My Business relationship folio, which contains the [woocommerce_my_account] shortcode, has both Login and Registration forms. But this is not always a good idea, more often than not when you use landing pages or sales pages with a specific goal eastward.g. user registration.
Clearly, when this happens, you don't want to have a login course there as well. My solution provides ii new shortcodes, one for the login class and one for the annals form.
Please be enlightened both shortcodes' content is copied from WooCommerce template files – if WooCommerce releases an update or makes a change to these files, you need to modify the shortcode coding too.
Give it a go, feedback is much appreciated 🙂
![](https://businessbloomer.com/wp-content/uploads/2019/02/woocommerce-separate-login-registration-pages.png)
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 Business relationship page at all costs.
This means, if you desire to continue the login course AND the "My Business relationship" dashboard while logged in on the same page, merely continue using [woocommerce_my_account] for that, together with Snippet #1.
To recap, if yous want to have LOGIN + MY ACCOUNT, and a separate REGISTRATION page, employ these 2 shortcodes:
- [wc_reg_form_bbloomer] on the Register Page
- [woocommerce_my_account] on the Login / My Account Page
If y'all want to take split up LOGIN, REGISTRATION and MY ACCOUNT pages so you demand 3 shortcodes:
- [wc_reg_form_bbloomer] on the Register Folio
- [wc_login_form_bbloomer] on the Login Page
- [woocommerce_my_account ] on the My Business relationship Folio
In both cases, you need to disable "Allow customers to create an account on the "My account" page":
![](https://businessbloomer.com/wp-content/uploads/2019/02/woocommerce-hide-registration-form-my-account.png)
Snippet #1 (PHP): Separate WooCommerce Client Registration (Shortcode)
Place this shortcode ([wc_reg_form_bbloomer]) in a brand new "Register" WordPress folio and the register form will magically appear.
/** * @snippet WooCommerce User Registration Shortcode * @how-to Get CustomizeWoo.com FREE * @writer Rodolfo Melogli * @uniform WooCommerce iv.0 * @donate $nine https://businessbloomer.com/bloomer-armada/ */ add_shortcode( 'wc_reg_form_bbloomer', 'bbloomer_separate_registration_form' ); function bbloomer_separate_registration_form() { if ( is_admin() ) render; if ( is_user_logged_in() ) return; ob_start(); // Annotation: THE Post-obit <Form></FORM> IS COPIED FROM woocommerce\templates\myaccount\course-login.php // IF WOOCOMMERCE RELEASES AN UPDATE TO THAT TEMPLATE, You MUST Modify THIS Accordingly do_action( 'woocommerce_before_customer_login_form' ); ?> <course method="mail" form="woocommerce-form woocommerce-form-annals annals" <?php do_action( 'woocommerce_register_form_tag' ); ?> > <?php do_action( 'woocommerce_register_form_start' ); ?> <?php if ( 'no' === get_option( 'woocommerce_registration_generate_username' ) ) : ?> <p course="woocommerce-class-row woocommerce-form-row--wide form-row course-row-wide"> <label for="reg_username"><?php esc_html_e( 'Username', 'woocommerce' ); ?> <span form="required">*</span></label> <input type="text" class="woocommerce-Input woocommerce-Input--text input-text" proper noun="username" id="reg_username" autocomplete="username" value="<?php echo ( ! empty( $_POST['username'] ) ) ? esc_attr( wp_unslash( $_POST['username'] ) ) : ''; ?>" /><?php // @codingStandardsIgnoreLine ?> </p> <?php endif; ?> <p class="woocommerce-form-row woocommerce-form-row--broad form-row form-row-wide"> <label for="reg_email"><?php esc_html_e( 'Email accost', 'woocommerce' ); ?> <span class="required">*</span></label> <input type="email" grade="woocommerce-Input woocommerce-Input--text input-text" proper noun="e-mail" id="reg_email" autocomplete="email" value="<?php echo ( ! empty( $_POST['email'] ) ) ? esc_attr( wp_unslash( $_POST['email'] ) ) : ''; ?>" /><?php // @codingStandardsIgnoreLine ?> </p> <?php if ( 'no' === get_option( 'woocommerce_registration_generate_password' ) ) : ?> <p class="woocommerce-grade-row woocommerce-form-row--wide form-row grade-row-wide"> <characterization for="reg_password"><?php esc_html_e( 'Password', 'woocommerce' ); ?> <span class="required">*</span></label> <input blazon="password" class="woocommerce-Input woocommerce-Input--text input-text" name="password" id="reg_password" autocomplete="new-countersign" /> </p> <?php else : ?> <p><?php esc_html_e( 'A password volition be sent to your electronic mail address.', 'woocommerce' ); ?></p> <?php endif; ?> <?php do_action( 'woocommerce_register_form' ); ?> <p class="woocommerce-FormRow form-row"> <?php wp_nonce_field( 'woocommerce-annals', 'woocommerce-register-nonce' ); ?> <button type="submit" class="woocommerce-Push button woocommerce-push button push woocommerce-form-register__submit" name="annals" value="<?php esc_attr_e( 'Register', 'woocommerce' ); ?>"><?php esc_html_e( 'Register', 'woocommerce' ); ?></button> </p> <?php do_action( 'woocommerce_register_form_end' ); ?> </form> <?php return ob_get_clean(); }
Snippet #2 (PHP): Split up WooCommerce Login (Shortcode)
Delight read the notes above – you might not need this shortcode at all and [woocommerce_my_account] may exist sufficient to show the login form.
Otherwise, please add this shortcode ([wc_login_form_bbloomer]) to a brand new Login folio.
/** * @snippet WooCommerce User Login Shortcode * @how-to Get CustomizeWoo.com FREE * @author Rodolfo Melogli * @compatible WooCommerce 4.0 * @donate $9 https://businessbloomer.com/bloomer-armada/ */ add_shortcode( 'wc_login_form_bbloomer', 'bbloomer_separate_login_form' ); function bbloomer_separate_login_form() { if ( is_admin() ) return; if ( is_user_logged_in() ) return; ob_start(); woocommerce_login_form( array( 'redirect' => 'https://custom.url' ) ); return ob_get_clean(); }
Where to add this snippet?
You can place PHP snippets at the bottom of your child theme functions.php file (delete "?>" if y'all have it there). CSS, on the other hand, goes in your child theme style.css file. Brand sure you know what you are doing when editing such files - if you lot need more guidance, please accept a look at my gratuitous video tutorial "Where to Identify WooCommerce Customization?"
Does this snippet (even so) work?
Please let me know in the comments if everything worked equally expected. I would be happy to revise the snippet if y'all study otherwise (please provide screenshots). I have tested this code with Storefront theme, the WooCommerce version listed to a higher place and a WordPress-friendly hosting on PHP 7.3.If you recollect this lawmaking saved yous time & coin, feel free to join fourteen,000+ WooCommerce Weekly subscribers for blog post updates or 250+ Business Bloomer supporters for 365 days of WooCommerce benefits. Cheers in advance :)
Need Help with WooCommerce?
Bank check out these costless video tutorials. You tin can learn how to customize WooCommerce without unnecessary plugins, how to properly configure the WooCommerce plugin settings and even how to master WooCommerce troubleshooting in case of a bug!
Join 150,000+ Monthly Readers & 14,000+ Subscribers.
Become a Business Bloomer Supporter.
See your Benefits →
How Tdo New Customers Register Woocommerce,
Source: https://www.businessbloomer.com/woocommerce-separate-login-registration/
Posted by: hicksnack1990.blogspot.com
0 Response to "How Tdo New Customers Register Woocommerce"
Post a Comment