PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Allowing a field to go into the database that is the same

  1. I know this is a weird request - but trust me it makes sense for my particular application. In the backend of Gravity Forms I have an email field checked with "No Duplicates". Is there a way in a hook to change this to allow duplicates at the last minute if the form meets a certain requirement?

    Posted 12 years ago on Friday September 14, 2012 | Permalink
  2. When you say "at the last minute", what stage of form submission are you talking about?

    Posted 12 years ago on Friday September 14, 2012 | Permalink
  3. Chris,

    I am trying this:

    add_action('gform_is_duplicate', 'allowDuplicateFields', 10, 4);
    function allowDuplicateFields($count, $form_id, $field, $value) {
    	 return 0;
    }

    but it is not working. Basically I want to manually override through a hook if I will accept a duplicate email. For simplicity sake lets say that I always wanted to validate a duplicate email as long as the value was test@test.com but require every other email to NOT be a duplicate.

    Does this make sense? Any help would be greatly appreciated.

    Thanks,
    Travis

    Posted 12 years ago on Friday September 14, 2012 | Permalink
  4. It looks like this function here should allow duplicates no matter what? Is that just for testing? Are there more rules in place that you trimmed here for brevity?

    If you export your form as XML (Import/Export menu item, then "Export Forms" from the top menu) and send me your functions.php to chris@rocketgenius.com I will take a look at this for you.

    Posted 12 years ago on Friday September 14, 2012 | Permalink
  5. Yes,

    I have the conditions outside this hook so it should allow all fields to validate no matter what but it is still catching them somehow. If might be because of this hook following it?:

    add_action("gform_after_submission", "gf_us_set_post_content", 10, 2);
    function gf_us_set_post_content($entry, $form){
    	RGFormsModel::save_lead($form, $lead);
    }

    I am trying to save this form back into the database to overwrite an existing entry. Does this hook appear like that is what it will do?

    Posted 12 years ago on Friday September 14, 2012 | Permalink
  6. Chris,

    I am not so sure if it is that the hooks arent doing what they are supposed to, it looks like they arent firing. Do you have any insight as to why they wouldnt be? I have them embedded in a Class of my own plugin but when I put them inside a conditional function it appears that they do not fire anymore unless they are under my INIT method.

    Thanks,
    Travis

    Posted 12 years ago on Friday September 14, 2012 | Permalink
  7. Can you try adding the function to your theme's functions.php rather than to a plugin file? It makes a difference sometimes where your function is located. The hooks were designed to be used in the theme's functions.php. If you can ensure the function works there first, you might be able to get it to work in your plugin.

    Posted 12 years ago on Friday September 14, 2012 | Permalink
  8. Chris,

    I will try to pull it outside my class and just call my class when I need to for the global variables I will set. Hopefully that will take care of the scope issues.

    Posted 12 years ago on Friday September 14, 2012 | Permalink
  9. Please let us know what you find out.

    Posted 12 years ago on Friday September 14, 2012 | Permalink