Last active
February 4, 2021 18:36
-
-
Save yousufansa/29b7fd6661eb6f4539b3f034e34f6802 to your computer and use it in GitHub Desktop.
Jobhunt - Add Password Confirm Field on WooCommerce Register Form
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if( ! function_exists( 'jh_child_woocommerce_register_form_confirm_password' ) ) { | |
| function jh_child_woocommerce_register_form_confirm_password() { | |
| if ( 'no' === get_option( 'woocommerce_registration_generate_password' ) ) { | |
| ?> | |
| <p class="form-row form-row-wide"> | |
| <label for="reg_confirm_password"><?php _e( 'Confirm Password ', 'jobhunt' ); ?> <span class="required">*</span></label> | |
| <input type="password" class="woocommerce-Input woocommerce-Input--text input-text" name="confirm_password" id="reg_confirm_password" autocomplete="new-password" /> | |
| </p> | |
| <div class="clear"></div> | |
| <?php | |
| } | |
| } | |
| } | |
| add_action( 'woocommerce_register_form', 'jh_child_woocommerce_register_form_confirm_password', 8 ); | |
| if( ! function_exists( 'jh_child_registration_errors_validation' ) ) { | |
| function jh_child_registration_errors_validation($reg_errors, $sanitized_user_login, $user_email) { | |
| global $woocommerce; | |
| extract( $_POST ); | |
| if ( strcmp( $password, $confirm_password ) !== 0 ) { | |
| return new WP_Error( 'registration-error', __( 'Passwords do not match.', 'jobhunt' ) ); | |
| } | |
| return $reg_errors; | |
| } | |
| } | |
| add_filter( 'woocommerce_registration_errors', 'jh_child_registration_errors_validation', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment