Share a global sequential unique ID across all forms

Sets a global sequential unique ID across all forms on the website.

Code

Filename: gpuid-global-sequential-id.php

<?php
/**
 * Gravity Perks // Unique ID // Share a global sequential unique ID across all forms
 * https://gravitywiz.com/documentation/gravity-forms-unique-id/
 *
 * Sets a global sequential unique ID across all forms on the website.
 *
 * To use this snippet, add Unique ID fields on all the forms you'd like to generate Unique IDs,
 * and update the $atts variable within the snippet to target any of the forms and its Unique ID field.
 *
 * Plugin Name:  GP Unique ID — Global Sequential ID
 * Plugin URI:   https://gravitywiz.com/documentation/gravity-forms-unique-id/
 * Description:  Sets a global sequential unique ID across all forms on the website.
 * Author:       Gravity Wiz
 * Version:      0.1
 * Author URI:   https://gravitywiz.com/
 */
add_filter( 'gpui_unique_id_attributes', 'gwiz_unique_id_global_sequential_index', 10, 3 );
function gwiz_unique_id_global_sequential_index( $atts, $form_id, $field_id ) {

	if ( $atts['type'] == 'sequential' ) {
		$atts['starting_number'] = 1;
		$atts['form_id']         = 1;
		$atts['field_id']        = 1;
	}

	return $atts;
}

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.