Add default user field to WooCommerce checkout

trying to add default user meta field “nickname” to the standard woo commerce user checkout user field. The examples on their website adds custom fields to order_meta – but it seems the dont use standard wordpress form functions. I have this outlined example, but need to hook add_user_meta to woocommerce_form_field.

* Add the field to the checkout
add_action( 'woocommerce_after_order_notes', 'my_custom_checkout_field' );

function my_custom_checkout_field( $checkout ) {

echo '<div id="my_custom_checkout_field"><h2>' . __('My Field') . '</h2>';

woocommerce_form_field( 'nickname', array(
    'type'          => 'text',
    'class'         => array('my-field-class form-row-wide'),
    'label'         => __('Agency Name'),
    'placeholder'   => __('Enter something'),
    ), $checkout->get_value( 'nickname' ));

echo '</div>';


* Process the checkout
add_action('woocommerce_checkout_process', 'my_custom_checkout_field_process');

function my_custom_checkout_field_process() {
// Check if set, if its not set add an error.
if ( ! $_POST['nickname'] )
    wc_add_notice( __( 'Please enter something into this new shiny field.' ), 'error' );

* Update the user meta with field value
add_action( 'user_hook', 'update_user_profile' );

function update_user_profile( $user_id ) {
   update_user_meta($user_id, 'nickname', $nickname);

Read more here: Add default user field to WooCommerce checkout

Leave a Reply

Your email address will not be published. Required fields are marked *