WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. grols
    Member
    Posted 1 year ago #

    Hi,
    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 :

    <script>
    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+"'>");
    </script>

    and in the message I put [AReference]

    http://wordpress.org/extend/plugins/contact-form-7/

  2. grols
    Member
    Posted 1 year ago #

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

  3. grols
    Member
    Posted 1 year ago #

    hi!
    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]

    Thanks

    Best wishes...

  4. Jim Daly
    Member
    Posted 1 year 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
    Member
    Posted 9 months 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?
    Please.
    Thanks
    See you soon...

  6. Jim Daly
    Member
    Posted 9 months 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

About this Topic