Gravity Wiz

Magically enhanced tutorials, snippets and plugins for Gravity Forms!

  • Gravity Perks
    • Gravity Perks
    • Tutorials & Snippets
    • About
  • Support
    • Documentation
    • Support
    • Account

Gravity Forms Unique ID

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

This plugin is part of Gravity Perks, a suite of 32+ essential Gravity Forms addons with support you can count on.

  • View All Perks
  • Buy Gravity Perks

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.

Documentation

  1. How do I enable this functionality?
  2. Feature Details
    1. How does it work?
    2. Field Settings
      1. Standard Settings
        1. Field Label
        2. Type
      2. Advanced Settings
        1. Starting Number
        2. Length
        3. Prefix
        4. Suffix
    3. Display the Generated Unique ID
  3. FAQs
    1. Can Unique ID generation be delayed until after payment is approved?
    2. Can I use a Unique ID as a username for the Gravity Forms User Registration Add-On?
    3. I added a Unique ID field to an existing form. Can I retroactively populate Unique IDs for previous entries?
  4. Hooks
  5. Related Articles

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

Standard Settings
gp-unique-id-field-settingsGP 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-field-settings-advancedGP 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 beginning 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.

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 this 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 this snippet to retroactively populated 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.

Hooks

  • gpui_form_editor_field_settings
  • gpui_numeric_minimum_length
  • gpui_sequential_unique_id_pre_insert
  • gpui_unique_id
  • gpui_unique_id_attributes
  • gpui_wait_for_payment
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.

Related Articles

  • How to Generate and Validate a Reference Number for Gravity Forms with GP Unique ID
  • Require an Existing Value for Submission with Gravity Forms

Perk Deets

  • Version 1.3.19
  • Updated April 2, 2020
  • Released August 20, 2014
  • View Changelog

Changelog

1.3.19

  • Added logging when unique ID is generated and saved to field.

1.3.18

  • Fixed conflict with GravityView where editing an entry with no fields configured would overwrite the value of Unique ID fields.

1.3.17

  • Fixed fatal error that could occur when Gravity Perks was activated but Gravity Forms was not.

1.3.16

  • Fixed issue where field settings were reset due to incorrect values in GP_Plugin variables.

1.3.15

  • Updated perk to use GP_Plugin framework.
  • Updated plugin author.

1.3.14

  • Updated no longer process unique IDs for partial entries.

1.3.13

  • Added "gpui_form_editor_field_settings" filter to allow filtering the field settings that appear in the Form Editor for Unique ID fields.

1.3.12

  • Added support for generating unique IDs when entries are added via the API.

1.3.11

  • Fixed issue where using merge tag inserter for Prefix and Suffix settings did not correctly save the inserted merge tag.

1.3.10

  • Updated core minimum length for numeric unique IDs to 6 (down from 9).
  • Added 'gpui_numeric_minimum_length' filter for setting the minimum length for numeric unique IDs.

1.3.9

  • Updated unique ID generation to respect the filtered length even if it is below our recommended minimum length.

1.3.7

  • Fixed backwards-compat issue with GF versions below 2.1 where Unique ID field label was visible on frontend.

1.3.6

  • Fixed backwards compatability issues with GF versions below 2.2.

1.3.5

  • Fixed notice generated when upgrading versions caused by use of deprecated Gravity Forms function.
  • Updated GP_Boostrap to version 1.2.

1.3.3

  • Updated Perk to be compatible with future versions of Gravity Forms.

1.3.2

  • Updated unique ID generation to happen on gform_entry_post_save priority 8 so that it will still be generated before GF feeds are processed but also give other plugins an oppurtunity (priority 9) to interact with unique ID before GF feeds as processed as well.

1.3.1

  • Added new filter for specifing a custom wait-for-payment feed; 'gpui_wait_for_payment_feed'.

1.3

  • Added support for merge tags in Prefix and Suffix settings.
  • Added support for waiting until PayPal Standard payment has been received (via gpui_wait_for_payment filter).
  • Updated field class to use the GF_Field class for better integration with Gravity Forms.

1.2.8

  • Added support for Unique ID fields in Notification routing
  • Minor refactoring

1.2.7

  • Updated perk to use GP_Bootstrap

1.2.6

  • Updated to support checking for posted value before generated new unique id

1.2.5

  • Updated priority of unique ID generation to occur before add-on framework processed feeds

1.2.4

  • Added inline documentation for the 'gpui_unique_id_attributes' filter

1.2.3

  • Added "gpui_input_html_options" filter for modifying input HTML; allows displaying input on frontend Example: https://gist.github.com/spivurno/aa5ffa48cb30728e0dd5
  • Added wrapper HTML to mimic default GF fields for cases where Unique ID field is actually displayed
  • Fixed typo in "Unique ID Suffix" tooltip

1.2.2

  • Added "gpui_sequential_unique_id_pre_insert" filter for custom handling of sequential IDs. Example: https://gist.github.com/spivurno/9a918859d7e5af2e7a92

1.2.1

  • Updated to avoid issue where unique IDs were overwritten when editing entry via Gravity View

1.2

  • Added better localization support

1.1.4

  • Added bootstrap support; fixes plugin order loading issue on Multisite installs

1.1.3

  • Fixed issue where default value was overwritten for unique ID field

1.1.2

  • Fixed issue where gpui_sequence table was not created due to missing $wpdb variable

1.1.1

  • Added support for setting $form_id and $field_id in 'gpui_unique_id_attributes' filter; this allows sharing unique ID indexes across multiple forms

1.1

  • Added support for conditional logic on Unique ID field
  • Updated GP_Unique_ID::field_obj to be public to better support custom modifications

1.0

  • Added support for resetting the starting number via the field settings

1.0.beta3.0

  • Added support for sequential unique IDs
  • Added support for uninstalling
  • Added starting number, length, prefix and suffix options (with UI)
  • Added UI for specifying the "type" of unique ID to be generated
  • Removed Unique ID merge tag support

1.0.beta2.1

  • Added filter 'gpui_unique_id' to support modifying the generated unique ID add_filter( 'gpui_unique_id', 'my_unique_id_modifier', 10, 3 ); function my_unique_id_attributes( $unique_id, $form_id, $field_id ) { return strtoupper( $unqiue ); }

1.0.beta2.0

  • Added filter 'gpui_unique_id_attributes' to support modifying the attributes used to generate the unique ID add_filter( 'gpui_unique_id_attributes', 'my_unique_id_attributes' ); function my_unique_id_attributes( $atts ) { $atts['length'] = 12; $atts['type'] = 'numeric'; return $atts; }
  • Added support for "numeric" UID type (not available in UI yet)
  • Add filter 'gpui_check_unique_query' to support modifing the query which ensures that the unique ID generated is unique add_filter( 'gpui_check_unique_query', 'my_check_unique_query' ); function my_check_unique_query( $query ) { $query['where'] = 'some change'; return $query; }
  • Fixed notice when "defaultValue" property not set on $field object

1.0.beta1.1

  • Updated documentation link to use the correct URL
  • Added changelog

1.0.beta1

  • And so it begins...

All Perks

  • GF Auto Login
  • GF Better User Activation
  • GF Blacklist
  • GF Conditional Logic Dates
  • GF Conditional Pricing
  • GF Copy Cat
  • GF Date Time Calculator
  • GF Disable Entry Creation
  • GF Easy Passthrough
  • GF eCommerce Fields
  • GF Email Users
  • GF Expand Textareas
  • GF File Upload Pro
  • GF Limit Checkboxes
  • GF Limit Choices
  • GF Limit Dates
  • GF Limit Submissions
  • GF Live Preview
  • GF Media Library
  • GF Multi-Page Navigation
  • GF Nested Forms
  • GF Pay Per Word
  • GF PayPal One-time Fee
  • GF Placeholder
  • GF Populate Anything
  • GF Post Content Merge Tags
  • GF Preview Submission
  • GF Price Range
  • GF Read Only
  • GF Reload Form
  • GF Terms Of Service
  • GF Unique ID
  • GF Word Count

Copyright © 2021 · Powered by WordPress · Gravity Wiz LLC

  • Support
  • Affiliates
  • About
  • Sitemap
  • Gravity Perks
    ▼
    • Gravity Perks
    • Tutorials & Snippets
    • About
  • Support
    ▼
    • Documentation
    • Support
    • Account