Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Williams – WPMU DEV Support

    (@wpmudev-support8)

    Hi @webteamkrusty

    I hope you’re well today and thank you for your question!

    I’ve got a working code for you that you can use to achieve this. It’s actually quite customizable so you can set you reference number format in various ways but for the format of “YEAR_number” you’ll need to do one small change.

    You’ll find the code here

    https://gist.github.com/adczk/fbf06b6abf7753df6b37234b13041e79

    and here is how to use it:

    1. remove those custom codes that you already tried first
    2. edit your form and

    – add a file of type “hidden” to it
    – make sure that this file has its “Default Value (optional)” option set to “Custom Value”; no need to put anything in “Custom Value” field though.
    – note down field id (e.g hidden-1)
    – edit your inline “thank you” message and add this to your “thank you” text where you want number to appear

    {formatted_value}

    – update form

    3. create an empty file with a .php extenions (e.g “forminator-auto-reference-number.php”)
    4. copy and paste code that I shared into that file
    5. configure the code

    a) in this line

    private $field_name = 'hidden-1';

    set the hidden field ID (if it’s different than hidden-1) that you’ve previously added to the form

    b) in this line

    private $form_ids = array( 1483 );

    replace the number 1483 with an ID of your form; it’s the same number that you see in form’s shortcode

    c) you can configure other settings according to comments in code but that’s optional

    d) replace this line (way down the code)

    $formatted_value = $this->prefix . $formatted_value . $this->suffix;

    with these two lines

    $this->prefix = date('Y').'_';
    $formatted_value = $this->prefix . $formatted_value . $this->suffix;

    6. save the file and upload it (using FTP or similar way) to the “/wp-content/mu-plugins” folder of your site’s WordPress installation; if there’s no “mu-plugins” folder inside “wp-content”, just create empty one first.

    If everything’s set up correctly this should work out of the box and:
    – thank you message would display the generated reference number
    – the same number will be saved in submission as value of the hidden field that you added to form
    – you can also include it in e-mail notifications (if all fields are included, it will be there out of the box; if you use individual fields, just include that hidden field).

    The code was created some time ago already but I just tested it a few minutes ago and I can confirm it still works fine.

    Best regards,
    Adam

    Thread Starter webteamkrusty

    (@webteamkrusty)

    Hi Adam @wpmudev-support8 thank you so much for your response! I followed your guide and it worked. I can’t thank you enough for guiding me! It also worked when I tried exporting the data (including the reference value) into a csv file.

    • This reply was modified 2 years, 4 months ago by webteamkrusty.
    tkriszta

    (@tkriszta)

    Hi!

    Is it possible to apply this solution to 2 forms so that they have different reference numbers?

    Thanks in advance!

    Plugin Support Williams – WPMU DEV Support

    (@wpmudev-support8)

    Hi @tkriszta

    It’s not possible to apply this code like this. It can be used with multiple forms but all forms will follow the same number format as set in the code.

    If you have any further/additional questions about this, please start a separate ticket of your own (as per this forum rules) and we’ll be happy to assist you there.

    Best regards,
    Adam

    tkriszta

    (@tkriszta)

    Dear Adam!

    Thank you! ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Creating reference number after form is submitted’ is closed to new replies.