Reputation: 115
In woocommerce form-edit-account.php
, i have the following but would only like to retain the Password and Confirm new password fields. I deleted all fields except Password and Confirm new password field but there is a validator that prompts me to fill up First Name, Last Name, Email address fields. How do i disable the validator for that? Really need help on this. Thanks in advance.
<?php
/**
* Edit account form
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 1.6.4
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
global $woocommerce;
?>
<?php wc_print_notices(); ?>
<form action="" method="post">
<p class="form-row form-row-first">
<label for="account_first_name"><?php _e( 'First name', 'woocommerce' ); ?> <span class="required">*</span></label>
<input type="text" class="input-text" name="account_first_name" id="account_first_name" value="<?php esc_attr_e( $user->first_name ); ?>" />
</p>
<p class="form-row form-row-last">
<label for="account_last_name"><?php _e( 'Last name', 'woocommerce' ); ?> <span class="required">*</span></label>
<input type="text" class="input-text" name="account_last_name" id="account_last_name" value="<?php esc_attr_e( $user->last_name ); ?>" />
</p>
<p class="form-row form-row-wide">
<label for="account_email"><?php _e( 'Email address', 'woocommerce' ); ?> <span class="required">*</span></label>
<input type="email" class="input-text" name="account_email" id="account_email" value="<?php esc_attr_e( $user->user_email ); ?>" />
</p>
<p class="form-row form-row-first">
<label for="password_1"><?php _e( 'Password (leave blank to leave unchanged)', 'woocommerce' ); ?></label>
<input type="password" class="input-text" name="password_1" id="password_1" />
</p>
<p class="form-row form-row-last">
<label for="password_2"><?php _e( 'Confirm new password', 'woocommerce' ); ?></label>
<input type="password" class="input-text" name="password_2" id="password_2" />
</p>
<div class="clear"></div>
<p><input type="submit" class="button" name="save_account_details" value="<?php _e( 'Save changes', 'woocommerce' ); ?>" /></p>
<?php wp_nonce_field( 'save_account_details' ); ?>
<input type="hidden" name="action" value="save_account_details" />
</form>
Upvotes: 1
Views: 7503
Reputation: 515
Well, I do that using this:
// Hook in
add_filter( 'woocommerce_default_address_fields' , 'custom_override_default_address_fields' );
function custom_override_default_address_fields( $fields ) {
unset($fields['first_name']);
return $fields;
}
It will remove the "First Name" field from both, billing and shipping address.
Upvotes: 2
Reputation: 31
After some quick research, the solution to exactly your problem, and also resently my problem.
Just add this to functions.php
add_filter( 'woocommerce_save_account_details_required_fields','custom_woocommerce_save_account_details_required_fields' );
function custom_woocommerce_save_account_details_required_fields( $required_fields ) {
unset($required_fields["account_first_name"]);
unset($required_fields["account_last_name"]);
return $required_fields;
}
It will remove the First Name field and Last Name field from the condition of required fields. Of course you can do that with all of your required inputs.
Upvotes: 3
Reputation: 1306
You can remove these validation manually.
Woocomaerce->includes->class-wc-form-handler.php find function
save_account_details()
edit this function or you can remove validation form here.
Upvotes: -2