Check if form was submitted by user/visitor #474
-
I am building a survey and want to limit submissions (cookie-based). If a user (not loggedin, aka visitor) has submitted a form, I want to hide the form and show the results instead, but unfortunately, I can't find the right way of getting the user's submission status. Can you give me a hint? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Sorry for the delay @jakobploens. I don't believe there's a way to do this at the moment, but I'll see if we can quickly add a way for it to work. 🙂 |
Beta Was this translation helpful? Give feedback.
-
This is now added in Freeform 4.0.9. 🙂 Freeform includes validation to prevent duplicate submissions (when the user tries to submit the form again), but if you wish to prevent users from even being able to see the form (and display an error/notice in its place), you can use {# Replace 'myForm' with your form handle. #}
{% set form = craft.freeform.form("myForm") %}
{# Check if user has already submitted the form #}
{% if form.submissionLimitReached %}
{# Hide form and display error message #}
<p class="alert">You've already submitted this form!</p>
{% else %}
{# Display form if not yet submitted by the user #}
{{ form.render }}
{% endif %} |
Beta Was this translation helpful? Give feedback.
This is now added in Freeform 4.0.9. 🙂
Freeform includes validation to prevent duplicate submissions (when the user tries to submit the form again), but if you wish to prevent users from even being able to see the form (and display an error/notice in its place), you can use
submissionLimitReached
(form object) as a conditional. It's a bool variable, which will betrue
if the form has the Limit Form Submission Rate setting enabled and the user has already submitted the form.