customize_validate_(id) filter-hookWP 4.6.0

Validates a Customize setting value.

Plugins should amend the $validity object via its WP_Error::add() method.

The dynamic portion of the hook name, $this->ID, refers to the setting ID.


add_filter( 'customize_validate_(id)', 'wp_kama_customize_validate_id_filter', 10, 3 );

 * Function for `customize_validate_(id)` filter-hook.
 * @param WP_Error             $validity Filtered from `true` to `WP_Error` when invalid.
 * @param mixed                $value    Value of the setting.
 * @param WP_Customize_Setting $setting  WP_Customize_Setting instance.
 * @return WP_Error
function wp_kama_customize_validate_id_filter( $validity, $value, $setting ){

	// filter...
	return $validity;
Filtered from true to WP_Error when invalid.
Value of the setting.
WP_Customize_Setting instance.


Since 4.6.0 Introduced.

Where the hook is called

wp-includes/class-wp-customize-setting.php 612
$validity = apply_filters( "customize_validate_{$this->id}", $validity, $value, $this );

Where the hook is used in WordPress

wp-includes/class-wp-customize-setting.php 200
add_filter( "customize_validate_{$this->id}", $this->validate_callback, 10, 3 );