Title: unique reference number
Last modified: February 21, 2023

---

# unique reference number

 *  Resolved [takkularapsis](https://wordpress.org/support/users/takkularapsis/)
 * (@takkularapsis)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/unique-reference-number/)
 * I dont understand the plugin use.
 * What i need is that when form is submitted the response mail headline would be
   having generate number ( six figures ). As unique reference number that is always
   generated afted submitting.
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Funique-reference-number%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 10 replies - 1 through 10 (of 10 total)

 *  Plugin Author [sevenspark](https://wordpress.org/support/users/sevenspark/)
 * (@sevenspark)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/unique-reference-number/#post-16492336)
 * Hi takkularapsis,
 * The plugin allows you to programmatically control the default value of a text
   input field in Contact Form 7, via a shortcode.
 * If you have a shortcode that produces the unique reference number you want, you
   could add that into the form, either as a text or hidden field. (You can use 
   any shortcode that returns a text value, or write your own custom shortcode to
   generate the value you need – there is no built in shortcode for unique reference
   number generation).
 * You could then include that value in the email that gets sent to you via mail
   tags, just like any Contact Form 7 field.
 * That said, if you want to generate a number *after* form submission, this plugin
   won’t help you, as these values are generated when the form is generated (on 
   page load), not on form submission.
 * Hope that helps
 *  Plugin Author [Tessa (they/them), AuRise Creative](https://wordpress.org/support/users/tessawatkinsllc/)
 * (@tessawatkinsllc)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/unique-reference-number/#post-16492478)
 * I don’t mean to butt in [@sevenspark](https://wordpress.org/support/users/sevenspark/)
   but I did create a built-in shortcode for unique reference number generation 
   😉
 * It’s simply `CF7_guid` but it generates a full GUID which isn’t limited to just
   6 characters, but [@takkularapsis](https://wordpress.org/support/users/takkularapsis/)
   you can use that shortcode as an example for writing your own ([view it in source code](https://plugins.trac.wordpress.org/browser/contact-form-7-dynamic-text-extension/tags/3.1.3/includes/shortcodes.php#L314)).
 *  Plugin Author [sevenspark](https://wordpress.org/support/users/sevenspark/)
 * (@sevenspark)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/unique-reference-number/#post-16492506)
 * [@tessawatkinsllc](https://wordpress.org/support/users/tessawatkinsllc/) yup 
   that’s worth pointing out 🙂
 * The GUID shortcode will create a value like this:
 *     ```wp-block-code
       730E00A3-3490-4D26-BB26-8BE6431D94F5
       ```
   
 * So neither 6 digits nor numeric; but if the requirement is just for a globally
   unique string, then it’s a great option 🙂
 *  Thread Starter [takkularapsis](https://wordpress.org/support/users/takkularapsis/)
 * (@takkularapsis)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/unique-reference-number/#post-16492602)
 * Ok, unfortunately that is too long. Should be 7 digits max. Ive tryid Google 
   every solution and php snippet without luck. Maybe ill just keep searching.
 *  Plugin Author [Tessa (they/them), AuRise Creative](https://wordpress.org/support/users/tessawatkinsllc/)
 * (@tessawatkinsllc)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/unique-reference-number/#post-16493253)
 * Our plugin gives you the framework to create custom shortcodes to fit your specific
   needs. You could add something like this to your active theme’s functions.php
   file that will return a number of 6 or 7 digits.
 *     ```wp-block-code
       function generate_reference_number() {
           $min = 100000; // Smallest 6-digit number
           $max = 9999999; // Largest 7-digit number
   
           if(function_exists('random_int')) { 
               return random_int($min, $max); // Secure, introduced in PHP 7.1
           } elseif(function_exists('mt_rand')) {
               return mt_rand($min, $max); // Less secure, but faster than rand()
           }
           return rand($min, $max); // Identical to mt_rand() as of PHP version 7.1
       }
       add_shortcode('get_reference_number', 'generate_reference_number');
       ```
   
 * And then add this to your form to create a hidden field that gets that number
   for you to use in the email.
 *     ```wp-block-code
       [dynamichidden refnumber "get_reference_number"]
       ```
   
 *  Thread Starter [takkularapsis](https://wordpress.org/support/users/takkularapsis/)
 * (@takkularapsis)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/unique-reference-number/#post-16494117)
 * Thank you, for your guidance, really appreciate it.
 * i tryid:
    1. I installed [Contact Form 7 – Dynamic Text Extension](https://wordpress.org/plugins/contact-form-7-dynamic-text-extension/)
    2. I added your snippet to PHP snippet plugin
    3. I added provided shortcode to form and to response mail
 * Did not get it work, this is the automatic response mail [https://snipboard.io/0lwpsC.jpg](https://snipboard.io/0lwpsC.jpg)
 *  Plugin Author [Tessa (they/them), AuRise Creative](https://wordpress.org/support/users/tessawatkinsllc/)
 * (@tessawatkinsllc)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/unique-reference-number/#post-16495005)
 * Ah, I can see what happened. I’m sorry I wasn’t clear. So you’ll want to add 
   the form tag to the **form** tab like this: [https://snipboard.io/qfn4xX.jpg](https://snipboard.io/qfn4xX.jpg)
 * And then in the **mail** tab, that’s where you use the simple `[refnumber]` shortcode
   as a placeholder, the same way you did for name like this: [https://snipboard.io/FwNuKj.jpg](https://snipboard.io/FwNuKj.jpg)
 * Then when the email sends, the `[refnumber]` in the mail template will be replaced
   by the content created in the custom shortcode you added via the PHP snippet 
   plugin.
 *  Thread Starter [takkularapsis](https://wordpress.org/support/users/takkularapsis/)
 * (@takkularapsis)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/unique-reference-number/#post-16495975)
 * Hi, thank you for your great guidance and patience. I managed to get the reference
   number that is now 7 digits and its ok.
 * But the bumer is always the same, should i do something to the php snippet i 
   added?
 * [https://snipboard.io/LGD5tJ.jpg](https://snipboard.io/LGD5tJ.jpg)
 *  [tasveer14](https://wordpress.org/support/users/tasveer14/)
 * (@tasveer14)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/unique-reference-number/#post-16969055)
 * Hello [@tessawatkinsllc](https://wordpress.org/support/users/tessawatkinsllc/)
   this seems to work perfectly Thx. However, is there a way to get the numbers 
   to be generated in order? eg: 000123 and the next submission 000124 ?
 * Thank you in advance
 *  Plugin Author [Tessa (they/them), AuRise Creative](https://wordpress.org/support/users/tessawatkinsllc/)
 * (@tessawatkinsllc)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/unique-reference-number/#post-16975403)
 * [@tasveer14](https://wordpress.org/support/users/tasveer14/) Can you ask your
   question in a new thread please? It helps me keep track since this one was marked
   as resolved and I didn’t see your recent post! Thanks!

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘unique reference number’ is closed to new replies.

 * ![](https://ps.w.org/contact-form-7-dynamic-text-extension/assets/icon-256x256.
   png?rev=3019574)
 * [Contact Form 7 - Dynamic Text Extension](https://wordpress.org/plugins/contact-form-7-dynamic-text-extension/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/contact-form-7-dynamic-text-extension/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/contact-form-7-dynamic-text-extension/)
 * [Active Topics](https://wordpress.org/support/plugin/contact-form-7-dynamic-text-extension/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/contact-form-7-dynamic-text-extension/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/contact-form-7-dynamic-text-extension/reviews/)

 * 10 replies
 * 4 participants
 * Last reply from: [Tessa (they/them), AuRise Creative](https://wordpress.org/support/users/tessawatkinsllc/)
 * Last activity: [2 years, 9 months ago](https://wordpress.org/support/topic/unique-reference-number/#post-16975403)
 * Status: resolved