Contact Form 7
How add a reference number by submit (6 posts)

  1. grols
    Posted 3 years ago #

    your plugin is very nice for me.
    I would like to add a reference number wich be generated by clicking the button of submission. How can I do please?
    I tried a little script in the form but if you don't refresh the page it's every time the same number if you submit more than one message (exemple of use : http://www.toulouseclubpatinage.com/leboncoin/)
    Thanks a lot for your help...
    See you soon

    exemple of script use in the top of the Form :

    var tD = new Date();
    var AReference=tD.getFullYear() + "/" + (tD.getMonth()+ 1) + "/" + tD.getDate() + "-" + tD.getHours()+tD.getMinutes()+tD.getSeconds();
    document.write("<input type='hidden' name='Ref_Annonce' value='"+AReference+"'>");

    and in the message I put [AReference]


  2. grols
    Posted 3 years ago #

    a little up...!
    Is there somebody to help me, please...?

  3. grols
    Posted 3 years ago #

    nobody to help me???

    a little bug in the message.... you have to see:
    and in the message I put [Ref_Annonce] and not [AReference]


    Best wishes...

  4. Jim Daly
    Posted 3 years ago #

    I managed to get something similar working. It generated a reference comprising the Unix timestamp with 4 random alphanumerics appended.

    This is the code I added to functions.php

    function genTicketString() {
        $length = 4;
        $characters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
        for ($p = 0; $p < $length; $p++) {
            $string .= $characters[mt_rand(0, strlen($characters)-1)];
    	$string = time() . $string;
        return $string;
    add_shortcode('quoteticket', 'genTicketString');

    I used the Contact Form 7 - Dynamic Text Extension plugin to allow me add the [quoteticket] shortcode to the form.

  5. grols
    Posted 2 years ago #

    Hi Jim
    Thanks a lot for your reply,
    I tried it but it don't match...
    I put your code in function.php of theme I use and I put in my form
    [dynamichidden Ref_Annonce "CF7_GET key='quoteticket'" ]
    what's wrong?
    See you soon...

  6. Jim Daly
    Posted 2 years ago #

    In your case [dynamichidden Ref_Annonce "quoteticket"] should work.

    Return the value in the email using [Ref_Annonce]

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Contact Form 7
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic