Creates Yearly Sequential IDs

Make the sequence for a given Unique ID field specific to the current year. The sequence will automatically reset each year.

Code

Filename: gpuid-yearly-sequential-ids.php

<?php
/**
 * GP Unique ID // Gravity Perks // Creates Yearly Sequential IDs
 * https://gravitywiz.com/documentation/gravity-forms-unique-id/
 *
 * Make the sequence for a given Unique ID field specific to the current year. The sequence
 * will automatically reset each year.
 */
// Update "123" to your form ID and "4" to your Unique ID field.
add_filter( 'gpui_unique_id_attributes_123_4', function( $atts ) {
	$atts['form_id'] = (int) gmdate( 'Y' ) . '0000';
	return $atts;
} );

Comments

  1. Stijn De Mulder
    Stijn De Mulder January 9, 2025 at 9:09 am

    Looks interesting but not sure it would fit my needs… Does this only affect the starting number?

    I have Starting Number: 1 Length: 3 Prefix: 456{date_created:format:y} Suffix: empty

    Reply
    1. Samuel Bassah
      Samuel Bassah Staff January 10, 2025 at 6:51 am

      Hi Stijn,

      Yes, this only affect the starting number, which is the generated unique number. If your use case is different and this won’t work for you, you can submit a ticket via our support form with details on how you want it to work, so we can assist you on how we can get the snippet or a modified version, working for you.

      Best,

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.