I was adding some functionality to a client’s website so visitors can purchase tickets to a yearly event. To do this, I used Gravity Forms and the Stripe Add-on.
The Notification sent to the buyer had almost all the necessary fields we wanted. But, there’s no native functionality to have a ticket number or unique ID for each entry.
I did some researching and found a genius answer from David over at Gravity Help.
What this code snippet does is use a Hidden Field (Advanced Tab Field). The script then puts your prefix if you’ve added one, along with a unique ID. This worked great to cross-reference during visitor check-in.
- In the Parameter Name of your Hidden Field, type uuid.
- Change the prefix on line 6 of the code snippet to what you’d like it to be
- Change the Form ID on line 21 of the code snippet to your form
- Change the Field ID on line 22 of the code snippet to the ID of the Hidden Field
Once you include the code snippet in your functions.php file, go to your form Notifications area and make sure you’re including the Hidden Field in your email. By default, Gravity Forms will display all fields within the notification.
Don’t Wanna Touch Any Code?
David from Gravity Wiz has written a WordPress Plugin called GP Unique ID. With this plugin, you get a new Gravity Forms field type within the Form Editor and you can specify the type of unique ID, even including sequential IDs, without having to touch any code.
Also checkout how to create a Notification Popup with Gravity Forms.
Tagged with: functions, gravity forms, wordpress
What do you think?
Do you have something to say about this post? Give us your opinion, insight, changes, or alternative way of doing something. We'd love to hear from you!
Glad my old snippet is still getting used! 🙂
I’ve actually improved that code quite a bit and provided a new Gravity Forms field type where you can specify the type of unique ID (included sequential IDs) without having to touch any code.
Your old snippet rocks 🙂 I’ll update the post with a link/description to the plugin, which has significant improvements.
Thanks for stopping by!
I’m a year late and not sure if i’ll get a response, but is there a way to make the Unique ID a number I choose and then have it add 1 to the number as it goes on? Thanks!
David Smith, the creator of the plugin mentioned, has this functionality in his plugin. I would highly suggest purchasing this for your needs.
For some reason the Unique ID only works when I’m logged in as admin. When I log out or go incognito the Unique ID result is empty. Any ideas what could be causing this?
Update: the problem was a cached version of functions.php 🙂
@Diana, thanks so much for the questions and the edited update. I appreciate you doing that. Glad you got it working.
How would I modify this code to use it for multiple forms each with a unique prefix?
You could just repeat this function and call it something different. For instance
Kevin you legend!
Now, I know I could buy the plugin from gravitywiz, but I am cheap so…
I’m trying to get a sequential, incremental number (so the first entry returns 100000, the second 100001 etc) is that achievable? ¯\_(ツ)_/¯