Advancedform - reference number

Third Party Plugins to CMSimple - how to install, use and create plugins

Moderator: Tata

bastingse
Posts: 308
Joined: Fri Jun 06, 2008 9:38 pm
Location: Netherlands
Contact:

Advancedform - reference number

Post by bastingse » Fri Oct 28, 2022 10:56 am

Hi foks,

I'm using the advancedforms plugin and i wonder if it is possible that, when somebody fill in a form, it generates a referencenumber that is send to the one who fill in the form and the webmaster.
By the way,... is it possible that the one who fill in the form gets a copy per mail?

Thanks in advance :-)

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: Advancedform - reference number

Post by cmb » Mon Oct 31, 2022 8:29 pm

bastingse wrote:
Fri Oct 28, 2022 10:56 am
By the way,... is it possible that the one who fill in the form gets a copy per mail?
Let's start with the simple question: that happens automatically, if no "thanks page" is defined. If a "thanks page" is defined, the user would have to copy&paste its contents to somewhere (or print it out). See also https://github.com/cmb69/advancedform_x ... /README.md; search for "confirmation" on that page.
bastingse wrote:
Fri Oct 28, 2022 10:56 am
I'm using the advancedforms plugin and i wonder if it is possible that, when somebody fill in a form, it generates a referencenumber that is send to the one who fill in the form and the webmaster.
That should be doable, if you don't need a "thanks page" (otherwise there is no confirmation mail). Probably the biggest issue is how this reference number can be generated; is it just about some arbitrary number? Does it even have to be a real number, or would some random string (say, hexdecimal, e.g. 1f56ab) suffice? That could be done via a mailform hook; I think I could come up with something.

Even simpler, if feasible, would be to add a text field to the form, and let users fill that out with a reference number chosen by themselves.
Christoph M. Becker – Plugins for CMSimple_XH

bastingse
Posts: 308
Joined: Fri Jun 06, 2008 9:38 pm
Location: Netherlands
Contact:

Re: Advancedform - reference number

Post by bastingse » Wed Nov 02, 2022 7:46 am

Thanks Christoph for your input, much appreciated!

I don't need a thankpage, an e-mail to the one who filled in the form is okay. My excuses... i never took time to read the manual regarding thankpage/thank e-mail, so that's 'new' for me :-) Great!!

A random string will do, as long as it is in the mail to the admin and to the sender.
Maybe this function would be handy for everyone? Just an extra option?

olape
Posts: 2731
Joined: Fri Mar 13, 2015 8:47 am
Contact:

Re: Advancedform - reference number

Post by olape » Wed Nov 02, 2022 10:24 am

I use "time" for this purpose.
In a different context, but that would certainly work for it too.
The result is a field with i.e. "1667383617" as content.

Create a field in the form (myform), with time.
"field": "time",
"label": "time",
"type: hidden,

The rest per hook
In the directory "data" of the plugin create a file myform.inc with the following content:

Code: Select all

<?php

if (!function_exists('advfrm_custom_field_default')) {
    function advfrm_custom_field_default($form_name, $field_name, $opt, $is_resent) {

        if ($field_name == 'time') {
            if (empty($_POST['advfrm-' . $field_name])) {
                return time();
            } else {
                return $_POST['advfrm-' . $field_name];
            }
        }
    }
}
Gruß Olaf, Plugins for CMSimple_XH

Ich habe schon lange den Verdacht, dass so viele so eifrig auf Gender, Trans und Queer machen:
Weil sie für das Fachliche ganz einfach zu doof sind.

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: Advancedform - reference number

Post by cmb » Wed Nov 02, 2022 11:38 am

olape wrote:
Wed Nov 02, 2022 10:24 am
I use "time" for this purpose.
Oh, that's nifty! That only has a resolution of 1 second, but that might be sufficient. If not, instead of time() you could use uniqid(), or even bin2hex(random_bytes(16)).
olape wrote:
Wed Nov 02, 2022 10:24 am
"type: hidden,
Are hidden fields sent to the form submitter? If not, just use a regular "text" field.
Christoph M. Becker – Plugins for CMSimple_XH

olape
Posts: 2731
Joined: Fri Mar 13, 2015 8:47 am
Contact:

Re: Advancedform - reference number

Post by olape » Wed Nov 02, 2022 1:23 pm

cmb wrote:
Wed Nov 02, 2022 11:38 am
Are hidden fields sent to the form submitter? If not, just use a regular "text" field.
I do not know whether the sender would receive them.
As the recipient, you also get the hidden fields.
Gruß Olaf, Plugins for CMSimple_XH

Ich habe schon lange den Verdacht, dass so viele so eifrig auf Gender, Trans und Queer machen:
Weil sie für das Fachliche ganz einfach zu doof sind.

bastingse
Posts: 308
Joined: Fri Jun 06, 2008 9:38 pm
Location: Netherlands
Contact:

Re: Advancedform - reference number

Post by bastingse » Thu Nov 03, 2022 3:27 pm

Thanks thanks !

Great idea and i'm gonna try things out. Will get back here with some feedback.
Thanks folks!

bastingse
Posts: 308
Joined: Fri Jun 06, 2008 9:38 pm
Location: Netherlands
Contact:

Re: Advancedform - reference number

Post by bastingse » Wed Nov 09, 2022 11:06 am

how hard i do try.... the sender does not get a copy per e-mail.
No, i don't use the 'thanks' page...??

lck
Posts: 2963
Joined: Wed Mar 23, 2011 11:43 am
Contact:

Re: Advancedform - reference number

Post by lck » Wed Nov 09, 2022 12:12 pm

help.htm wrote:After successful submission of the form, an email will be sent to the receivers (To, CC and BCC) specified in the form editor. Then the sent information is displayed to the visitors as confirmation, or, if a thanks page is specified, the visitors will be redirected there, and a confirmation mail will be sent to them. The thanks page/confirmation feature will only work, if a required field of type Sender (e-mail) is specified for the form, and Mail → Confirmation is enabled in the configuration.
„Bevor du den Pfeil der Wahrheit abschießt, tauche die Spitze in Honig!“   👉 Ludwig's XH-Templates for MultiPage & OnePage

bastingse
Posts: 308
Joined: Fri Jun 06, 2008 9:38 pm
Location: Netherlands
Contact:

Re: Advancedform - reference number

Post by bastingse » Wed Nov 09, 2022 12:20 pm

Thanks!!
Now the mail is receive!! (i thought the thankpage should not be use)... anyway.....
I got it work and the webmaster is receiving an email with the 'time' field', but the sender does not receive that information in his mail :-(

Post Reply