Block access to a form if a specific entry exists

Hello,

I created a multi-step form with a hidden “utm_key” field in the first step.
To get people to enter my form, I send them an email with a custom link with a “utm_key” parameter in the URL.

I would like to deny access to the form to all people who have already answered the form by checking if the utm_key already exists in the answers of the form in question.
Not during submission. Really at the very beginning of the form, when the person arrives at the form URL with the “utm_key” parameter filled in.

If utm_key already exists in the form inputs, then I display a text that says: “You cannot refill this form…”
If utm_key does not exist in the form inputs, then the person has access to the form.

Someone help me find out how to do it?

Thanks

Can you enable the ‘no duplicates’ setting for the field that stores the ‘utm_key’? That would prevent them from being able to submit the form more than one time with that key.

Hello and thanks for your reply
It’s not possible to enable the ‘no duplicates’ because it’s hidden field
I really want to block access to the form before starting, not at the end, because the form is very long with multi steps

Hi Jonathan. In that case, you will need another approach. You will need to use some custom code to check to see if the entry exists before you display the form, and then display a message rather than the form.

To prevent the form from showing, you can use the gform_get_form_filter:

If you need to check to see if a specific utm_key was submitted in a previous entry, you can use the GFAPI::get_entries function:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.