No Duplicates conditional logic

Hi all! So I am trying to use the “No Duplicates” option on an email field to do some conditional logic. Ive exhausted my Google-Fu and thought the good people here may have some suggestions or solutions.

So with that said here is what I am trying to do. I have a form with a single Email field. If the email address has been used before Id like to display a page’s content. If the address is unique I would like to open a conditional section to capture the users information (email, name, and the like) and then pass them on to the page content. The second half the of the logic I understand and can setup, its just getting past the “if ($duplicate) this; else that;” portion. Any help would be greatly appreciated!

Is that actually the only field in the form, and then the form is submitted? And after submission, if that email was submitted already, you show the page content, otherwise, you show another form, and then the page content?

Currently, yes, there is the Email input and a submit button. Ideally, if the email address wasnt already submitted it would just open a conditional section and collect the rest of the data needed, then redirect to the content.

I think it will definitely be easier to do it with two forms. If the first form just accepts the email address, you can use the gform_confirmation filter to check to see if this address was previously submitted in the form.

To check to see if the email address was previously submitted, you can use the GFAPI::get_entries function:

And check the returned data for that address. If there is a match (they previously submitted their email address) you can use a Confirmation redirect to redirect to your content page. If the email address was not previously submitted, you can use the Confirmation to redirect to another form, where you collect more data, and then show the content.

Thank you! That makes perfect sense!

1 Like