Check if the current user has submitted a Gravity Forms form before

Continuing the discussion from CHECK IF THE CURRENT USER HAS SUBMITTED A GRAVITY FROM BEFORE SHOWING CONTENT. If they have hide form:

Sam - any chance you figured out how to get this to work? I’m looking into something similar for a customer of ours.

Hi Rich. Can you let us know what you’re looking to accomplish exactly, in your environment? We can better help you if we know the end goal. Thank you.

I have a custom post type (Event) that users can view the details of. They can submitted a form (Gravity Form) to register for the event. The site will have hundreds of events (volunteer opportunities to be exact). I will reuse the same Gravity Form to allow logged in users to register to attend the event. The user can register for multiples. When the logged in user goes back to a previously registered event, I would like to show them a message “You have already registered for this event”, instead of showing them the form again.

Hi Rich. Let me see if I can summarize and if I understand. You have many posts (custom post type: Event) and on each post, you are going to embed the same registration form. A logged in user can submit that form multiple times, but only once per post (event). Is that accurate?

So, when they are viewing a post (event) which they have already registered (submitted the form for) you want to show them a message rather than showing them the form, so they can’t submit the form again? Is that accurate?

Yes - exactly

1 Like

Hi Rich. In order to prevent the form from showing for an event, for a specific user who has already submitted that form, you will need to use the gform_get_form_filter:

That is where you can decide to show a form or show a message, based on your conditions. In your case the condition will be if this logged in user already has a submission for this event. So, before the form is shown, you will need to know the event. I’m not sure if that is the post title, or post ID or a custom field, but you will need that information. And you will need to grab the user’s ID or username or email, whatever is stored in the entry for them.

Then, you can use the GFAPI::get_entries function:

to determine if an entry with your criteria (the post ID or post name, and the user-identifying information) was already submitted. If so, return a message “You have already registered for this event”. If not, return the form.

It should be possible with this filter, this API function, and some PHP. If you need any other ideas, please let us know.

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

© 2008 - 2021. Gravity Forms is a project by Rocketgenius Inc.