Following the instructions for setting up WooCommerce validation fields, follow these steps:
Setting up validation fields using actions and filters
I added a custom field to the woocommerce validation page via functions.php .
I'm worried if I need to sanitize user login for this custom field?
I think that he does not need to be disinfected, since he went to billing fields, as in: $ fields ['billing'], is that right?
If not, how do I sanitize this custom field?
Creating this custom field means that text strings (Latin) and integers are combined with a maximum length of 50.
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
function custom_override_checkout_fields( $fields ) {
$fields['billing']['billing_username'] = array(
'type' => 'text',
'label' => __('Your Username', 'woocommerce'),
'placeholder' => _x('', 'placeholder', 'woocommerce'),
'required' => true,
'class' => array('form-row-first'),
'clear' => true
);
return $fields;
}