Don’t allow duplicate entries on prepopulated fields


I am trying to use the “no duplicate” setting for a field that is prepopulated via a defined filter.

This does not seem te work. Does the prepopulation function override the no duplicate setting?


The no duplicates setting is enforced when the form is submitted (upon validation.) If you populate the field when the form is rendered, when that is submitted, it should return a validation error if there is already a value in an entry that is the same.

Can you share the code you are using to populate the value in the field?

This is my code to populate the field:

add_filter('gform_field_value_kort_lidnummer', 'populate_author_lidnummer');
function populate_author_lidnummer($value){ 
    $user_ID = get_current_user_id();
    $key = 'kort_lidnummer';
    $single = true; 
    return get_user_meta($user_ID, $key, $single);

Thank you for the code. I just tested this on my server and it is working as expected. I pre-populated a field with a value. Created the entry. Loaded the form again. The field is pre-populated with the same value (the code was designed to do this.) When I submit the form, I get back a validation error “This field requires a unique entry and ‘ba209999-0c6c-11d2-97cf-00c04f8eea45’ has already been used”

If it’s not working like that for you, chances are your code is not returning unique values for each user. The Gravity Forms functionality is working as expected, but I think there is something wrong with your approach.