acf_field_email::validate_value
Validate the email value. If this method returns TRUE, the input value is valid. If FALSE or a string is returned, the input value is invalid and the user is shown a notice. If a string is returned, the string is show as the message text.
Method of the class: acf_field_email{}
No Hooks.
Returns
true|false|String.
Usage
$acf_field_email = new acf_field_email(); $acf_field_email->validate_value( $valid, $value, $field, $input );
- $valid(true|false) (required)
- Whether the value is valid.
- $value(mixed) (required)
- The field value.
- $field(array) (required)
- The field array.
- $input(string) (required)
- The request variable name for the inbound field.
acf_field_email::validate_value() acf field email::validate value code ACF 6.0.4
public function validate_value( $valid, $value, $field, $input ) {
$flags = defined( 'FILTER_FLAG_EMAIL_UNICODE' ) ? FILTER_FLAG_EMAIL_UNICODE : 0;
if ( $value && filter_var( wp_unslash( $value ), FILTER_VALIDATE_EMAIL, $flags ) === false ) {
return sprintf( __( "'%s' is not a valid email address", 'acf' ), esc_html( $value ) );
}
return $valid;
}