E
E
Elio Don2019-07-18 12:07:57
WordPress
Elio Don, 2019-07-18 12:07:57

How to change field order in Woocommerce registration form?

Added an arbitrary field using the manual , as well as code in function.php that allows you to display password confirmation

spoiler
add_filter('woocommerce_registration_errors', 'registration_errors_validation', 10,10);
function registration_errors_validation($reg_errors, $sanitized_user_login, $user_email) {
global $woocommerce;
extract( $_POST );
 
if ( strcmp( $password, $password2 ) !== 0 ) {
return new WP_Error( 'registration-error', __( 'Пароли не совпадают.', 'woocommerce' ) );
}
return $reg_errors;
}
 
add_action( 'woocommerce_register_form', 'wc_register_form_password_repeat' );
function wc_register_form_password_repeat() {
?>
<p class="form-row form-row-wide">
<label for="reg_password2"><?php _e( 'Повторите Ваш пароль', 'woocommerce' ); ?> <span class="required">*</span></label>
<input type="password" class="input-text" name="password2" id="reg_password2" value="<?php if ( ! empty( $_POST['password2'] ) ) echo esc_attr( $_POST['password2'] ); ?>" />
</p>
<?php
}

But a problem arose, the phone number was located between the password entry fields, I tried to make priorities, I did not really understand how to declare them so that they would work.
How to move the phone number field to the very top or bottom?
5d3036a8681f7735820894.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
deadnice, 2019-07-18
@deadnice

Through the filter "woocommerce_register_form" the field can only be added at the end

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question