2

I'm working on a Woocommerce website and I just came across this problem:

when I go to Account page and I'm asked to create a new account, in the form there isn't the "Username" field. There are just these fields:

  • Email (default of Woocommerce)
  • Password (default of Woocommerce)
  • School number (custom field added with FMA Additional Registration Attributes(Free))

I don't get why I'm not asked to create a username as well. Every time an account is created, I get automatically the first part of the email as username.

Example: If I created an account with this email: [email protected], I'd get this username: test.test

I don't want Wordpress to create it automatically for me, I'd like to allow the user to create their own username.

I tried to open this file: woocommerce/myaccount/form-login.php

and I edited this line by commenting the IF:

    <?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 _e( 'Username', 'woocommerce' ); ?> <span class="required">*</span></label>
            <input type="text" class="woocommerce-Input woocommerce-Input--text input-text" name="username" id="reg_username" value="<?php echo ( ! empty( $_POST['username'] ) ) ? esc_attr( $_POST['username'] ) : ''; ?>" />
        </p>

    <?php //endif; ?>

After this, the filed was shown but everything remained the same I could fill out the field but it was completelly useless, woocommerce kept using the email to create the account.

I don't know where to look at now to solve this issue.

Is there something else useful that I can tell to make you understand better the problem?

1 Answer 1

4

I just fund the tricky solution, it was very simple and I did think about it.

I just went to WooCommerce -> Settings -> Accounts and I untick the checkbox for "Automatically generate username from customer email".

I got the solution from this topic but here the problem was the contrary:

https://stackoverflow.com/questions/32781569/remove-username-field-registration-form-woocommerce

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.