myaccount registration added check for auto generate password option
This commit is contained in:
parent
ce2f2e1c3d
commit
afc17dad40
|
@ -848,16 +848,22 @@ class WC_Form_Handler {
|
|||
|
||||
wp_verify_nonce( $_POST['register'], 'woocommerce-register' );
|
||||
|
||||
if ( 'no' == get_option( 'woocommerce_registration_generate_username' ) ) {
|
||||
if ( 'no' === get_option( 'woocommerce_registration_generate_username' ) ) {
|
||||
$_username = $_POST['username'];
|
||||
} else {
|
||||
$_username = '';
|
||||
}
|
||||
|
||||
if ( 'no' === get_option( 'woocommerce_registration_generate_password' ) ) {
|
||||
$_password = $_POST['password'];
|
||||
} else {
|
||||
$_password = '';
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
$validation_error = new WP_Error();
|
||||
$validation_error = apply_filters( 'woocommerce_process_registration_errors', $validation_error, $_username, $_POST['password'], $_POST['email'] );
|
||||
$validation_error = apply_filters( 'woocommerce_process_registration_errors', $validation_error, $_username, $_password, $_POST['email'] );
|
||||
|
||||
if ( $validation_error->get_error_code() ) {
|
||||
throw new Exception( '<strong>' . __( 'Error', 'woocommerce' ) . ':</strong> ' . $validation_error->get_error_message() );
|
||||
|
@ -872,7 +878,7 @@ class WC_Form_Handler {
|
|||
|
||||
$username = ! empty( $_username ) ? wc_clean( $_username ) : '';
|
||||
$email = ! empty( $_POST['email'] ) ? wc_clean( $_POST['email'] ) : '';
|
||||
$password = ! empty( $_POST['password'] ) ? wc_clean( $_POST['password'] ) : '';
|
||||
$password = wc_clean( $_password );
|
||||
|
||||
// Anti-spam trap
|
||||
if ( ! empty( $_POST['email_2'] ) ) {
|
||||
|
|
|
@ -24,7 +24,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
* @return bool
|
||||
*/
|
||||
function wc_disable_admin_bar( $show_admin_bar ) {
|
||||
if ( apply_filters( 'woocommerce_disable_admin_bar', get_option( 'woocommerce_lock_down_admin', 'yes' ) == 'yes' ) && ! ( current_user_can( 'edit_posts' ) || current_user_can( 'manage_woocommerce' ) ) ) {
|
||||
if ( apply_filters( 'woocommerce_disable_admin_bar', get_option( 'woocommerce_lock_down_admin', 'yes' ) === 'yes' ) && ! ( current_user_can( 'edit_posts' ) || current_user_can( 'manage_woocommerce' ) ) ) {
|
||||
$show_admin_bar = false;
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ function wc_create_new_customer( $email, $username = '', $password = '' ) {
|
|||
}
|
||||
|
||||
// Handle username creation
|
||||
if ( 'no' == get_option( 'woocommerce_registration_generate_username' ) || ! empty( $username ) ) {
|
||||
if ( 'no' === get_option( 'woocommerce_registration_generate_username' ) || ! empty( $username ) ) {
|
||||
|
||||
$username = sanitize_user( $username );
|
||||
|
||||
|
@ -78,11 +78,13 @@ function wc_create_new_customer( $email, $username = '', $password = '' ) {
|
|||
}
|
||||
|
||||
// Handle password creation
|
||||
if ( 'yes' == get_option( 'woocommerce_registration_generate_password' ) && empty( $password ) && ! isset( $_POST['register'] ) ) {
|
||||
if ( 'yes' === get_option( 'woocommerce_registration_generate_password' ) && empty( $password ) ) {
|
||||
$password = wp_generate_password();
|
||||
$password_generated = true;
|
||||
|
||||
} elseif ( empty( $password ) ) {
|
||||
return new WP_Error( 'registration-error', __( 'Please enter an account password.', 'woocommerce' ) );
|
||||
|
||||
} else {
|
||||
$password_generated = false;
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|||
|
||||
<?php do_action( 'woocommerce_register_form_start' ); ?>
|
||||
|
||||
<?php if ( get_option( 'woocommerce_registration_generate_username' ) === 'no' ) : ?>
|
||||
<?php if ( 'no' === get_option( 'woocommerce_registration_generate_username' ) ) : ?>
|
||||
|
||||
<p class="form-row form-row-wide">
|
||||
<label for="reg_username"><?php _e( 'Username', 'woocommerce' ); ?> <span class="required">*</span></label>
|
||||
|
@ -80,10 +80,14 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|||
<input type="email" class="input-text" name="email" id="reg_email" value="<?php if ( ! empty( $_POST['email'] ) ) echo esc_attr( $_POST['email'] ); ?>" />
|
||||
</p>
|
||||
|
||||
<p class="form-row form-row-wide">
|
||||
<label for="reg_password"><?php _e( 'Password', 'woocommerce' ); ?> <span class="required">*</span></label>
|
||||
<input type="password" class="input-text" name="password" id="reg_password" value="<?php if ( ! empty( $_POST['password'] ) ) echo esc_attr( $_POST['password'] ); ?>" />
|
||||
</p>
|
||||
<?php if ( 'no' === get_option( 'woocommerce_registration_generate_password' ) ) : ?>
|
||||
|
||||
<p class="form-row form-row-wide">
|
||||
<label for="reg_password"><?php _e( 'Password', 'woocommerce' ); ?> <span class="required">*</span></label>
|
||||
<input type="password" class="input-text" name="password" id="reg_password" value="<?php if ( ! empty( $_POST['password'] ) ) echo esc_attr( $_POST['password'] ); ?>" />
|
||||
</p>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- Spam Trap -->
|
||||
<div style="left:-999em; position:absolute;"><label for="trap"><?php _e( 'Anti-spam', 'woocommerce' ); ?></label><input type="text" name="email_2" id="trap" tabindex="-1" /></div>
|
||||
|
|
Loading…
Reference in New Issue