Gform is duplicate

Description

This filter is executed during the validation of fields marked with the "No Duplicates" rule. Use this hook to specify a custom duplicate validation logic.

Usage

Applies to all forms

<?php
add_action('gform_is_duplicate', 'duplicate_logic', 10, 4);
?>


Applies to a specific form. In this case, form Id 5

<?php
add_action('gform_is_duplicate_5', 'duplicate_logic', 10, 4);
?>

Parameters

$count

(int) The number of duplicate entries. Filtering this value to 0 means there are no duplicates.

$form_id

(int) The current form's id.

$field

(Field Object) The current field being validated

$value

(string) The value of the current field

Examples

This example checks to see if the email address is already in use. If so, consider the email a duplicate and return a count of 1; otherwise return a count of 0.


<?php
add_action('gform_is_duplicate', 'noDuplicateEMails', 10, 4);
function noDuplicateEMails($count, $form_id, $field, $value) {
   if ( $field['type'] == 'email' && get_user_by('email', $value) )
     return 1;
   else
     return 0;	
}
?>

Source Code

This filter is located in forms_model.php

Search the Documentation