Description
The gform_value_pre_duplicate_check
filter allows for the modification of the field value just before the duplicate check.
Usage
Applies to all forms:
add_filter( 'gform_value_pre_duplicate_check', 'your_function_name', 10, 3);
Parameters
- $value string
The value being checked against existing entries for duplicates. - $field GF_Field
The field being checked for duplicates. - $form_id int
The ID of the form being checked for duplicates.
Examples
Sanitize an email
Sanitize emails and consider values like [email protected]
the same as [email protected]
add_filter( 'gform_value_pre_duplicate_check', function ( $value, $field, $form_id ) {
if ( $field->type !== 'email' ) {
return $value;
}
$value = strtolower( $value );
if ( strpos( $value, '@gmail.com' ) === false || strpos( $value, '+' ) === false ) {
return $value;
}
$username = str_replace( '@gmail.com', '' , $value );
$username = substr( $username, 0 , strpos( $username, '+' ) );
return $username . '@gmail.com';
}, 10, 3 );
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?
Source Code
This filter is located in /form_display.php
Since
The filter was added in Gravity Forms 2.9.2