Create field and save as user meta
-
Hi,
Can i create fields with your plugin and the save them to user meta in functions.php ?
For example for a billing_birthdate field:add_action( 'woocommerce_checkout_update_customer', 'save_account_billing_new_field', 10, 2 ); function save_account_billing_new_field( $customer, $data ){ if ( isset($_POST['billing_birthdate']) && ! empty($_POST['billing_birthdate']) ) { $customer->update_meta_data( 'billing_birthdate', sanitize_text_field($_POST['billing_birthdate']) ); } } // WordPress User: Add Billing new editable field add_filter('woocommerce_customer_meta_fields', 'wordpress_user_account_billing_new_field'); function wordpress_user_account_billing_birthdate_field( $fields ) { $fields['billing']['fields']['billing_birthdate'] = array( 'label' => __('Date de naissance', 'woocommerce'), 'description' => __('', 'woocommerce') ); return $fields; }
- The topic ‘Create field and save as user meta’ is closed to new replies.