• Resolved takkularapsis

    (@takkularapsis)


    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 to see the link]

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author sevenspark

    (@sevenspark)

    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

    (@tessawatkinsllc)

    I don’t mean to butt in @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 you can use that shortcode as an example for writing your own (view it in source code).

    Plugin Author sevenspark

    (@sevenspark)

    @tessawatkinsllc yup that’s worth pointing out ??

    The GUID shortcode will create a value like this:

    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

    (@takkularapsis)

    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

    (@tessawatkinsllc)

    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.

    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.

    [dynamichidden refnumber "get_reference_number"]
    Thread Starter takkularapsis

    (@takkularapsis)

    Thank you, for your guidance, really appreciate it.

    i tryid:

    1. I installed 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

    Plugin Author Tessa (they/them), AuRise Creative

    (@tessawatkinsllc)

    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

    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

    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

    (@takkularapsis)

    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

    Hello @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

    (@tessawatkinsllc)

    @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.