Gravity Forms Unique ID

Generate alphanumeric, numeric or sequential “Unique ID” values for the entry when submitted. Applications are endless!

What does it do?

This plugin provides a new Unique ID field type which generates a unique ID for the entry when submitted. Some common uses for this perk are:

  • Provide a set-length confirmation or reference number for each entry; could be displayed on the confirmation page and in notifications (i.e. “Your confirmation number is ABC142Z3”).
  • Maintain a sequential invoice number (a legal requirement for some countries)
  • Generate a unique coupon code that can be used on subsequent form submissions (tutorial coming soon!)
  • Generate a unique number for use in raffles

There are probably a hundred other ways this could be used. We would really love to hear how you’re using it!

Features

  • Generate unique IDs on form submission.
    Every form entry is assigned a unique ID.
  • Supports alphanumeric, numeric, and sequential numbering.
    Select the unique ID type that fits best.
  • Specify starting number, length, prefix, and suffix.
    Customize ID generation to your specific use case.
  • Merge tag support.
    Display Unique ID in form Confirmations, Notifications, and more!
  • Automatic updates.
    Get updates and latest features right in your dashboard.
  • Awesome support.
    We’re here to help! And we mean it.

How do I enable this functionality?

After installing and activating Gravity Forms Unique ID, you’ll want to add a Unique ID field to your form. Let’s step through that process.

Create a new Form or navigate to any existing Form. Find the Unique ID button under the Advanced Fields group. Click it to add the field to your form.
Modify the field settings as needed. See below for full details on the available field settings.

That’s it! Your form now has a Unique ID field that will automatically generate a unique ID when the form is submitted.


Feature Details

How does it work?

When a form containing a Unique ID field is submitted, a unique ID is generated and populated for this field. The ID is unique to the form and field.

It’s important to note that in order to guarantee that the ID is truly unique, the field is populated only after the form has been successfully submitted. Since the field has no value prior to submission, this field is not visible on the frontend.

Field Settings

General Settings
GP Unique ID Standard Field Settings
Field Label

The label of the field. Visible in the {all_fields} merge tag and on the entry detail and entry list views.

Type

The type of unique ID that will be generated for this field.

  • Alphanumeric
    Contains letters and numbers (i.e. a12z9).
  • Numeric
    Contains only numbers (i.e. 152315902).
  • Sequential
    Contains only numbers and is sequential with previously generated IDs per field (i.e. 1, 2, 3).
Advanced Settings
GP Unique ID Advanced Field Settings
Starting Number

Set the starting number for sequential IDs; only available when “Sequential” type is selected.

Length

Set a specific length for the generated ID (excluding the prefix and suffix) or leave empty to use default length. There are some differences in length requirements for each ID type.

  • Alphanumeric
    Requires a minimum length of 4.
  • Numeric
    Requires a minimum length of 9 and a maximum length of 19.
  • Sequential
    Length is used to pad the number with zeros (i.e. an ID of 1 with a length of 5 would be 00001). There is no minimum length.
Prefix

Prepend a short string to the beginning of the generated ID (i.e. abc123890678). You can use merge tags; the list is available via the “Merge Tags” icon located on the right of the field.

Suffix

Append a short string to the end of the generated ID (i.e. 123890678xyz). You can use merge tags; the list is available via the “Merge Tags” icon located on the right of the field.

Display the Generated Unique ID

You can display the unique ID generated for any unique ID field using the merge tag for that field. This will be available in the Gravity Forms’ default merge tag lists.

Unique ID fields are automatically included in Gravity Forms {all_fields} merge tag.

Usage Examples

Integrations

Gravity Forms File Renamer

File Renamer can automatically rename files uploaded to Gravity Forms and it integrates seamlessly with Unique ID. Create flexible naming templates with static or dynamic values, automatically create new subfolders on upload, and control when files are incremented or how they’re deduplicated.

With Unique ID, filenames can be given sequential numbers and unique alphanumeric IDs. Simply insert the Unique ID field’s merge tag into the File Template — no additional configuration required.

Gravity PDF’s Invoicing Templates

Unique ID integrates with Gravity PDF’s Invoicing 2.0+ templates. These templates allow for business-ready invoice generation from Gravity Forms submissions. They’re highly customizable, translatable, support conditional logic, and are GST/VAT compatible. GP Unique ID’s sequential, alphanumeric, or numeric values can be leveraged when invoices are generated using Gravity PDF.

There’s a variety of templates to choose from and all templates integrate with GP Advanced Calculations, GP Inventory, GP Conditional Pricing, GP eCommerce Fields, and GP Price Range. Learn more about Gravity PDF’s invoicing templates here.

FAQs

Can Unique ID generation be delayed until after payment is approved?

If your form uses a first-party payment add-on (or a third-party payment add-on compatible with the Gravity Forms Payment Add-On Framework) then the unique ID can be generated once payment has been captured. This delay is enabled via the gpui_wait_for_payment filter.

Can I use a Unique ID as a username for the Gravity Forms User Registration Add-On?

Normally, the User Registration Add-On will throw a validation error since validation happens before the unique ID is generated. Use the following snippet to bypass the validation when a Unique ID field is configured for the username.

I added a Unique ID field to an existing form. Can I retroactively populate Unique IDs for previous entries?

You sure can! Use the following snippet to retroactively populate Unique ID fields. To use it, go to your home page and add the following parameters to the query string:

gpui_retro_pop=1&form_id=123

Make sure to replace 123 with your Form ID. The full URL will look like this:

https://mysite.com/?gpui_retro_pop=1&form_id=123

After the URL is submitted, you’ll be greeted with a success message and updated entry count.

How do I set a global Unique ID?

Use the following snippet to set a global, sequential unique ID across all forms on your site. To use this snippet on your site, update the $atts section of the snippet to use your starting number, Form ID, and Field ID where the Unique ID is being generated from.

How do I share a sequence across multiple Unique ID fields?

You can share sequences between sequential Unique ID fields by using the snippet below. It even works with fields on different forms, too!

To use this snippet on your site, replace the numbers in the $groups array with your form and field IDs.

For example, if Form A’s ID is 123 and its Unique ID field’s ID is 1, while Form B’s ID is 456 and its Unique ID field’s ID is 2, then you would set up the group like this:

$groups = array(
     array(
         123 => 1,
         456 => 2,
     )
 );

Known Limitations

  • If you’re using GP Unique ID 1.5 or higher, please do not downgrade to a lower version. Due to a database update in version 1.5, downgrading will cause unique ID sequences to no longer work.

Hooks

Gravity Forms has hundreds of hooks. Check out our Gravity Forms Hook Reference for the most thorough guide to Gravity Forms’ many actions and filters.


Grab a bundle of free Gravity Forms plugins

Enter your email and receive our most popular free plugins and snippets, plus access to hundreds of others.

This field is for validation purposes and should be left unchanged.