woocommerce_validate_phone
Filters whether a phone number is considered valid.
Usage
add_filter( 'woocommerce_validate_phone', 'wp_kama_woocommerce_validate_phone_filter', 10, 3 );
/**
* Function for `woocommerce_validate_phone` filter-hook.
*
* @param bool $valid Whether the phone number passed the default validation.
* @param string $phone The phone number being validated.
* @param string|null $country The country code the phone is being validated for, or null if unknown.
*
* @return bool
*/
function wp_kama_woocommerce_validate_phone_filter( $valid, $phone, $country ){
// filter...
return $valid;
}
- $valid(true|false)
- Whether the phone number passed the default validation.
- $phone(string)
- The phone number being validated.
- $country(string|null)
- The country code the phone is being validated for, or null if unknown.
Changelog
| Since 11.0.0 | Introduced. |
Where the hook is called
woocommerce_validate_phone
woocommerce/includes/class-wc-validation.php 64
return (bool) apply_filters( 'woocommerce_validate_phone', $valid, $phone, $country );