Add ability in contact form to reply to the submitter
Permalink 2 users found helpful
I thought it would be nice to make an email form on a C5 site and allow people to include a "reply to" or "from" address. Currently, C5 only has the option to include the owner of the page in the "from" portion of the emailed form. This gets really annoying if you use the form for questions and feedback because you have to copy+paste the email address into a new email and reply that way.
I wrote a simple fix on the PHP page SITE/concrete/blocks/form/controller.php
Just make the change below (simply search for one of the lines to find the right place, somewhere in the lines 300 to 350 territory, and you can figure out the rest):
and this change:
This makes the "email" field of a form into the "from" or "reply to" field when it arrives in your inbox. It would be nice if this were added to C5 permanently, but it's a really easy fix even if they don't.
I wrote a simple fix on the PHP page SITE/concrete/blocks/form/controller.php
Just make the change below (simply search for one of the lines to find the right place, somewhere in the lines 300 to 350 territory, and you can figure out the rest):
}elseif($row['inputType']=='email'){ $answerLong=""; $answer=$txt->sanitize($_POST['Question'.$row['msqID']]); // New line below. $fromEmail=$answer;
and this change:
$mh->to( $this->recipientEmail ); // $mh->from( $formFormEmailAddress ); is the old line $mh->from( $fromEmail ); // is the new line
This makes the "email" field of a form into the "from" or "reply to" field when it arrives in your inbox. It would be nice if this were added to C5 permanently, but it's a really easy fix even if they don't.
I am not sure what you're asking. If you have changed something, but the behavior of the form is not changing, try clearing the cache in the dashboard.
Hi Curtis,
thank you for posting this, I am trying to figure out how to get to the correct place to make that change. I've tried through 'edit block and design', could you direct me to the right location?
Thank you!
thank you for posting this, I am trying to figure out how to get to the correct place to make that change. I've tried through 'edit block and design', could you direct me to the right location?
Thank you!
You have to get the file using FTP and then edit it using a text editor. I explained where you find it in the post.
I've also tried this code, and for it worked until I started updating my sites to the most recent version. Something has changed, but not sure what. Anybody else experience this?
Thank you curtis for these lines. Worked great for me (I modified it a bit to change only the replyto-Adress).
@SamS: You should not change any code in the /concrete/ directory and below.
Always copy files you want to change into the correct path below your root outside /concrete/ because otherwise your patch will not work after updates.
If anybody needs a more detailed process I tried my explanation here:
http://www.concrete5.org/index.php?cID=167731...
@SamS: You should not change any code in the /concrete/ directory and below.
Always copy files you want to change into the correct path below your root outside /concrete/ because otherwise your patch will not work after updates.
If anybody needs a more detailed process I tried my explanation here:
http://www.concrete5.org/index.php?cID=167731...
The whole structure has changed in concrete5 5.6.x. The code can no longer be found in /concrete/blocks/form/controller.php. Instead, now you can check a checkbox in the form designer when you add an email field. But the problem is: the checking is not saved. I tried on two different web hosting environments, but it does not work. Does anybody have a fix for this?
/concrete/core/controllers/blocks/form.php
I couldn't get the Reply to to do anything either...so here is a rather horrible hack that sends a second email at the same time
around line 445
$mh = Loader::helper('mail');
$mh->to( $this->recipientEmail );
$mh->from( $formFormEmailAddress );
$mh->replyto( $replyToEmailAddress );
$mh->addParameter('formName', $this->surveyName);
$mh->addParameter('questionSetId', $this->questionSetId);
$mh->addParameter('questionAnswerPairs', $questionAnswerPairs);
$mh->load('block_form_submission');
$mh->setSubject(t('%s Form Submission', $this->surveyName));
//echo $mh->body.'<br>';
@$mh->sendMail();
This sends the first email -
Directly underneath add this
$mh2 = Loader::helper('mail');
$mh2->to( $replyToEmailAddress );
$mh2->from( $formFormEmailAddress );
$mh2->addParameter('formName', $this->surveyName);
$mh2->addParameter('questionSetId', $this->questionSetId);
$mh2->addParameter('questionAnswerPairs', $questionAnswerPairs);
$mh2->load('block_form_submission');
$mh2->setSubject(t('%s Form Submission', $this->surveyName));
//echo $mh2->body.'<br>';
@$mh2->sendMail();
This will fire an email back to the replytoemailaddress that was collected as the email in the form.
I hope this works for you!
I couldn't get the Reply to to do anything either...so here is a rather horrible hack that sends a second email at the same time
around line 445
$mh = Loader::helper('mail');
$mh->to( $this->recipientEmail );
$mh->from( $formFormEmailAddress );
$mh->replyto( $replyToEmailAddress );
$mh->addParameter('formName', $this->surveyName);
$mh->addParameter('questionSetId', $this->questionSetId);
$mh->addParameter('questionAnswerPairs', $questionAnswerPairs);
$mh->load('block_form_submission');
$mh->setSubject(t('%s Form Submission', $this->surveyName));
//echo $mh->body.'<br>';
@$mh->sendMail();
This sends the first email -
Directly underneath add this
$mh2 = Loader::helper('mail');
$mh2->to( $replyToEmailAddress );
$mh2->from( $formFormEmailAddress );
$mh2->addParameter('formName', $this->surveyName);
$mh2->addParameter('questionSetId', $this->questionSetId);
$mh2->addParameter('questionAnswerPairs', $questionAnswerPairs);
$mh2->load('block_form_submission');
$mh2->setSubject(t('%s Form Submission', $this->surveyName));
//echo $mh2->body.'<br>';
@$mh2->sendMail();
This will fire an email back to the replytoemailaddress that was collected as the email in the form.
I hope this works for you!
Thank you for this. It worked perfectly for me today.
I changed the lines in this file:
SITE/concrete/core/controllers/blocks/form.php
I changed the lines in this file:
SITE/concrete/core/controllers/blocks/form.php
How do you create an input type of email in the contact form. The selection only includes:
Text Field
Text Area
Radio Buttons
Select Box
Checkbox List
File Upload
my results were that my email from line was concrete5-noreply@myurl.com