gform_email_field_rejectable_values

Description

The gform_email_field_rejectable_values allows developers to define specific email addresses or partial email patterns that should be rejected during form validation.

Usage

The following would apply to all forms.

add_filter( 'gform_email_field_rejectable_values', 'your_function_name', 10, 3 );

To limit the scope of your function to a specific form, append the form id to the end of the hook name. (format: gform_email_field_rejectable_values_FORMID)

add_filter( 'gform_email_field_rejectable_values_123', 'your_function_name', 10, 3 );

Parameters

ParameterTypeDescription
$rejectable_valuesarrayAn array of values or partial values to be rejected.
$emailstringThe submitted email value being validated.
$fieldGF_Field_EmailThe email field object being validated.

Examples

Reject any email addresses containing the word ‘testing‘.

add_filter( 'gform_email_field_rejectable_values', function ( $values ) {
	$values[] = 'testing';

	return $values;
} );

Reject specific domains.

add_filter( 'gform_email_field_rejectable_values', function ( $values ) {
	$values[] = '@gmail.com';
	$values[] = '@mailinator';

	return $values;
} );

Placement

This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.

See also the PHP section in this article: Where Do I Put This Code?

Since

Gravity Forms 2.9.15

Source Code

This filter is located in includes/fields/class-gf-field-email.php