• Resolved panda

    (@alejorostata)


    I’m creating a separate Login and Registration page for Customers and Vendors. Login page works as expected however not on Registration Page.

    The following code is copied from the original file of Woocommerce login-form.php, I use it as shortcode from functions.php to display the registration form on a separate page.

    add_shortcode( 'wc_registration_form', 'wc_registration_form_content' );
        
    function wc_registration_form_content() {
       if ( is_admin() ) return;
       if ( is_user_logged_in() ) return;
       ob_start();
     
       // NOTE: THE FOLLOWING <FORM></FORM> IS COPIED FROM woocommerce\templates\myaccount\form-login.php
      
       do_action( 'woocommerce_before_customer_login_form' );
       ?>
          <form method="post" class="woocommerce-form woocommerce-form-register register" <?php do_action( 'woocommerce_register_form_tag' ); ?> >
             <?php do_action( 'woocommerce_register_form_start' ); ?>
             <?php if ( 'no' === get_option( 'woocommerce_registration_generate_username' ) ) : ?>
                <p class="woocommerce-form-row woocommerce-form-row--wide form-row form-row-wide">
                   <label for="reg_username"><?php esc_html_e( 'Username', 'woocommerce' ); ?> <span class="required">*</span></label>
                   <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 ?>
                </p>
             <?php endif; ?>
             <p class="woocommerce-form-row woocommerce-form-row--wide form-row form-row-wide">
                <label for="reg_email"><?php esc_html_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" 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-form-row woocommerce-form-row--wide form-row form-row-wide">
                   <label for="reg_password"><?php esc_html_e( 'Password', 'woocommerce' ); ?> <span class="required">*</span></label>
                   <input type="password" class="woocommerce-Input woocommerce-Input--text input-text" name="password" id="reg_password" autocomplete="new-password" />
                </p>
             <?php else : ?>
                <p><?php esc_html_e( 'A password will be sent to your email address.', 'woocommerce' ); ?></p>
             <?php endif; ?>
             <?php do_action( 'woocommerce_register_form' ); ?>
             <p class="woocommerce-FormRow form-row">
                <?php wp_nonce_field( 'woocommerce-register', 'woocommerce-register-nonce' ); ?>
                <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>
             </p>
             <?php do_action( 'woocommerce_register_form_end' ); ?>
          </form>
       <?php    
       return ob_get_clean();
    }

    The registration form is not submitting, the page is not even reloading after clicking the Register button nor hitting the Enter Key from the keyboard, after a lot of troubleshooting, it looks like the issue is somewhat related to Dokan plugin. I tried deactivating the plugin and the registration form is working and submitting correctly, reactivating the Dokan plugin will make the issue again. How to solve this?

    • This topic was modified 4 years, 5 months ago by panda.
Viewing 7 replies - 1 through 7 (of 7 total)
  • Hello @alejorostata,

    I am not sure why you are doing custom code. There is a plugin to create separate login page and also, you can create separate vendor registration forms easily with the plugin. Kindly follow this post and check if it helps or not.

    Cheers!

    Thread Starter panda

    (@alejorostata)

    I don’t need to use another plugin for the Login Page since the Woocommerce default login page works already, I just did some CSS customization on it, and it’s great and working perfectly.

    Same with the Registration Page for Vendors, the instructions actually came from that post, I added the shortcode into the new page, used CSS to customize the interface and it works great and perfect.

    The only issue is on the Registration page for customers, the form is not submitting. The instructions for separate page of registration came from this link. It’s working perfectly fine before, without Dokan. After installing Dokan, the form is no longer submitting.

    I tried to deactivate and reactivate all of my plugins and the only cause of the form not submitting is the Dokan.

    I checked my console and after clicking the submit button of Registration Form, the following errors are shown.

    An invalid form control with name='fname' is not focusable.
    An invalid form control with name='lname' is not focusable.
    An invalid form control with name='shopname' is not focusable.
    An invalid form control with name='shopurl' is not focusable.
    An invalid form control with name='phone' is not focusable.

    It seems like there are missing Javascript or JQuery causing the form not to submit.

    Here’s the structure of the Login/Registration Pages;
    Login-page = “Customers and Vendors”
    Registration page vendor = “Vendors only”
    Registration page = “Customers only”

    Thanks for the reply anyway, I’m almost onto switching alternative plugin.

    • This reply was modified 4 years, 5 months ago by panda.

    Hello @alejorostata,

    I am not sure if you are using the paid version or not. Please note [dokan-vendor-registration] shortcode will work only with the paid version. The Free version does not have any separate vendor registration functionality. If you have seen the blog link I sent where I have shown how to create separate registration form for the vendor and it works perfectly.

    If you are using the paid version then kindly create a ticket to our own support forum then we will take a look and resolve.

    Thread Starter panda

    (@alejorostata)

    I’m using the lite version of Dokan and yes, the shortcode is working even for the lite-version. I’m not ready to purchase the paid version because I’m still working on the development and I still want to check the basic functionality of the plugin.

    My query is not actually related to the separate registration for Vendor because it’s working correctly and I don’t have any issue of using it so disregard the vendor registration. The issue is on the default registration form for customers of Woocommerce.

    I’ve used the default registration form of Woocommerce, I copied it from the original file which is located in woocommerce/templates/myaccount/login-form.php then put it into my functions.php to create a shortcode of it and it’s working fine.

    After installing and using the Dokan plugin, I’m surprised that just right after activating it, the registration form for the customer is no longer working, it’s not submitting. I’ve checked my console and the following error is being generated every time I submit the form.

    
    An invalid form control with name='fname' is not focusable.
    An invalid form control with name='lname' is not focusable.
    An invalid form control with name='shopname' is not focusable.
    An invalid form control with name='shopurl' is not focusable.
    An invalid form control with name='phone' is not focusable.

    I think there is a missing piece of the code, probably a hook to make it work again. Clearly from the console, the form is not submitting because it is being blocked by the error.

    • This reply was modified 4 years, 5 months ago by panda.

    Hello @alejorostata ,

    You are right that Dokan is using one of the action hook to add the vendor registration form fields in the regular WooCommerce registration form.

    You have two options now.

    1. Remove the Dokan vendor registration field from all registration form by using this code in your theme’s functions.php file –

    remove_action( 'woocommerce_register_form', 'dokan_seller_reg_form_fields' );

    You may use WordPress conditional tags to disable the hook on a particular page/page template.

    2. You can also delete the hook from your template – https://prnt.sc/tdbpki

    I hope this solves the issue you are having.

    Thank you.

    Thread Starter panda

    (@alejorostata)

    I see, so that’s it. Everything is working now.

    Hello @alejorostata ,

    Glad to be helpful ??

    Regards,
    Rashed.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Woocommerce Registration Form for a separate page not submitting or not working’ is closed to new replies.