WordPress filter hook

woocommerce_form_field

Defined by WooCommerce and fired by 6 plugins in total, running on 7.1M+ sites between them.

“General filter on form fields.”

How to use woocommerce_form_field

It's a filter: your callback receives the value and 3 more arguments, and must return the (changed) value. Add this to your theme's functions.php or a small custom plugin:

functions.php
add_filter( 'woocommerce_form_field', function( $field, $key, $args, $value ) {
	// Change $field here.
	return $field;
}, 10, 4 );

Argument names come from WooCommerce's source. Other plugins may pass different values: check the call in the plugin you're targeting below.

6 plugins that fire woocommerce_form_field

Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.

  1. WooCommerce icon WooCommerce7+ million installs apply_filters( 'woocommerce_form_field', $field, $key, $args, $value ) includes/wc-template-functions.php:3625
  2. ShopLentor icon ShopLentor80,000+ installs apply_filters( 'woocommerce_form_field', $field, $key, $args, $value ) includes/modules/shopify-like-checkout/includes/classes/Frontend/Manage_Checkout.php:787
  3. FunnelKit icon FunnelKit30,000+ installs apply_filters( 'woocommerce_form_field', $field, $key, $args, $value ) modules/checkouts/includes/functions.php:355
  4. Sublium Subscriptions icon Sublium Subscriptions700+ installs apply_filters( 'woocommerce_form_field', $field, $key, $args, $value ) includes/helpers/utility.php:1178
  5. ShopPress icon ShopPress600+ installs apply_filters( 'woocommerce_form_field', $field, $key, $args, $value ) Modules/Shopify.php:367
  6. TrafficFlow OnePageCheckout for WooCommerce icon TrafficFlow OnePageCheckout for WooCommerce10+ installs apply_filters( 'woocommerce_form_field', $html, $key, $args, $value ) includes/class-opcw-fields.php:834

Need a customisation built on this hook?

Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.