New Landing How can we help? Atelier Adding Password Confirmation

Viewing 7 posts - 1 through 7 (of 7 total)
  • Posted in: Atelier
  • #184785
    busho
    Member
    Post count: 14

    Hi,

    Since Woocommerce 2.1, they’ve removed the password confirmation field. There are guide for adding such a field to the login/register page, however, I am unfamiliar with the current one used in /atelier/woocommerce/myaccount/form-login.php

    The guide just suggests to add this to functions.php:

    <?php
    // place the following code in your theme's functions.php file
    // Add a second password field to the checkout page.
    add_action( 'woocommerce_checkout_init', 'wc_add_confirm_password_checkout', 10, 1 );
    function wc_add_confirm_password_checkout( $checkout ) {
    	if ( get_option( 'woocommerce_registration_generate_password' ) == 'no' ) {
    		$checkout->checkout_fields['account']['account_password2'] = array(
    			'type' 				=> 'password',
    			'label' 			=> __( 'Confirm password', 'woocommerce' ),
    			'required'          => true,
    			'placeholder' 		=> _x( 'Confirm Password', 'placeholder', 'woocommerce' )
    		);
    	}
    }
    
    // Check the password and confirm password fields match before allow checkout to proceed.
    add_action( 'woocommerce_after_checkout_validation', 'wc_check_confirm_password_matches_checkout', 10, 2 );
    function wc_check_confirm_password_matches_checkout( $posted ) {
    	$checkout = WC()->checkout;
    	if ( ! is_user_logged_in() && ( $checkout->must_create_account || ! empty( $posted['createaccount'] ) ) ) {
    		if ( strcmp( $posted['account_password'], $posted['account_password2'] ) !== 0 ) {
    			wc_add_notice( __( 'Passwords do not match.', 'woocommerce' ), 'error' );
    		}
    	}
    }
    ?>
    #184790
    busho
    Member
    Post count: 14

    Oops, wrong code:

    <?php
    // Add the code below to your theme's functions.php file to add a confirm password field on the register form under My Accounts.
    add_filter('woocommerce_registration_errors', 'registration_errors_validation', 10,3);
    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', __( 'Passwords do not match.', '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( 'Password Repeat', '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
    }
    ?>
    #184902
    Kyle – SUPPORT
    Moderator
    Post count: 35880

    Hi

    Have you tried adding this to your child theme’s functions.php file?

    – Kyle

    #205419
    mikefrisbee
    Member
    Post count: 76

    Kyle,

    How/where do we access the child theme’s functions.php file and how do we edit it?

    #205420
    Rui Guerreiro – SUPPORT
    Keymaster
    Post count: 25779

    Hi,

    You should install and activate the child theme .zip file that is inside the downloadable zip from Themeforest.

    that child theme will contain 2 files(style.css and functions.php)

    -Rui

    #205434
    mikefrisbee
    Member
    Post count: 76

    Rui,

    I’ve installed the Atelier child theme.

    If I activate and move to that theme, will I still have all the settings/designs etc? Basically, everything will look the same? I don’t want to lose anything.

    Will I then be able to see and edit the functions.php file, like I can with the CSS at the moment?

    #205440
    Rui Guerreiro – SUPPORT
    Keymaster
    Post count: 25779

    Hi,

    Install this one.
    http://d.pr/f/1g3vO/BidKOX65

    -Rui

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in and have valid license to reply to this topic.

License required for one of the following items
Login and Registration Log in · Register