WooCommerce: Validate custom fields on My Account's edit page WooCommerce: Validate custom fields on My Account's edit page wordpress wordpress

WooCommerce: Validate custom fields on My Account's edit page


You could try to use one of this 2 hooks for validating custom fields.

add_action( 'user_profile_update_errors','wooc_validate_custom_field', 10, 1 );// oradd_action( 'woocommerce_save_account_details_errors','wooc_validate_custom_field', 10, 1 );// with something like:function wooc_validate_custom_field( $args ){    if ( isset( $_POST['custom_field'] ) ) // Your custom field    {        if(strlen($_POST['custom_field'])<4 ) // condition to be adapted        $args->add( 'error', __( 'Your error message', 'woocommerce' ),'');    }}