woocommerce registration form shortcode

Solutions on MaxInterview for woocommerce registration form shortcode by the best coders in the world

showing results for - "woocommerce registration form shortcode"
Maelia
01 May 2017
1/**
2 * @snippet       WooCommerce User Registration Shortcode
3 * @how-to        Get CustomizeWoo.com FREE
4 * @author        Rodolfo Melogli
5 * @compatible    WooCommerce 4.0
6 * @donate $9     https://businessbloomer.com/bloomer-armada/
7 */
8   
9add_shortcode( 'wc_reg_form_bbloomer', 'bbloomer_separate_registration_form' );
10    
11function bbloomer_separate_registration_form() {
12   if ( is_admin() ) return;
13   if ( is_user_logged_in() ) return;
14   ob_start();
15 
16   // NOTE: THE FOLLOWING <FORM></FORM> IS COPIED FROM woocommerce\templates\myaccount\form-login.php
17   // IF WOOCOMMERCE RELEASES AN UPDATE TO THAT TEMPLATE, YOU MUST CHANGE THIS ACCORDINGLY
18 
19   do_action( 'woocommerce_before_customer_login_form' );
20 
21   ?>
22      <form method="post" class="woocommerce-form woocommerce-form-register register" <?php do_action( 'woocommerce_register_form_tag' ); ?> >
23 
24         <?php do_action( 'woocommerce_register_form_start' ); ?>
25 
26         <?php if ( 'no' === get_option( 'woocommerce_registration_generate_username' ) ) : ?>
27 
28            <p class="woocommerce-form-row woocommerce-form-row--wide form-row form-row-wide">
29               <label for="reg_username"><?php esc_html_e( 'Username', 'woocommerce' ); ?> <span class="required">*</span></label>
30               <input type="text" class="woocommerce-Input woocommerce-Input--text input-text" name="username" id="reg_username" autocomplete="username" value="<?php echo ( ! empty( $_POST['username'] ) ) ? esc_attr( wp_unslash( $_POST['username'] ) ) : ''; ?>" /><?php // @codingStandardsIgnoreLine ?>
31            </p>
32 
33         <?php endif; ?>
34 
35         <p class="woocommerce-form-row woocommerce-form-row--wide form-row form-row-wide">
36            <label for="reg_email"><?php esc_html_e( 'Email address', 'woocommerce' ); ?> <span class="required">*</span></label>
37            <input type="email" class="woocommerce-Input woocommerce-Input--text input-text" name="email" id="reg_email" autocomplete="email" value="<?php echo ( ! empty( $_POST['email'] ) ) ? esc_attr( wp_unslash( $_POST['email'] ) ) : ''; ?>" /><?php // @codingStandardsIgnoreLine ?>
38         </p>
39 
40         <?php if ( 'no' === get_option( 'woocommerce_registration_generate_password' ) ) : ?>
41 
42            <p class="woocommerce-form-row woocommerce-form-row--wide form-row form-row-wide">
43               <label for="reg_password"><?php esc_html_e( 'Password', 'woocommerce' ); ?> <span class="required">*</span></label>
44               <input type="password" class="woocommerce-Input woocommerce-Input--text input-text" name="password" id="reg_password" autocomplete="new-password" />
45            </p>
46 
47         <?php else : ?>
48 
49            <p><?php esc_html_e( 'A password will be sent to your email address.', 'woocommerce' ); ?></p>
50 
51         <?php endif; ?>
52 
53         <?php do_action( 'woocommerce_register_form' ); ?>
54 
55         <p class="woocommerce-FormRow form-row">
56            <?php wp_nonce_field( 'woocommerce-register', 'woocommerce-register-nonce' ); ?>
57            <button type="submit" class="woocommerce-Button woocommerce-button button woocommerce-form-register__submit" name="register" value="<?php esc_attr_e( 'Register', 'woocommerce' ); ?>"><?php esc_html_e( 'Register', 'woocommerce' ); ?></button>
58         </p>
59 
60         <?php do_action( 'woocommerce_register_form_end' ); ?>
61 
62      </form>
63 
64   <?php
65     
66   return ob_get_clean();
67}
68