Forums

Email subject

dbrody 21 Mar, 2011
Is it possible to put the results of a field into the subject of the email. For instance if we had a radio button, {radio0}, and specified the subject "Results - {radio0}", would this work?
GreyHead 21 Mar, 2011
Hi dbrody,

Not in ChronoForms 3.2 but you can get the same result by defining a new variable in the OnSubmit Before Email box. There's an example here

Bob
dbrody 21 Mar, 2011
Tried that, here is the code.

<?php
$name =& JRequest::getString('radio0', '', 'post');
$subject = 'Sample Request - ';
if ( $name ) {
$subject .= $name;
}
JRequest::setVar('subject', $subject);
?>

It seems like it is still pulling the subject from the Setup Emails tab. If I don't have a subject in the setup emails tab, it won't allow emailing. Even if I had the radio0 tag wrong, it still show me "Sample Request -", but instead shows whatever the subject is in the setup emails tab.
GreyHead 22 Mar, 2011
Hi dbrody,

You need a Dynamic Subject in the Email Setup to get this to work OK.

Bob
dbrody 22 Mar, 2011
Ok, got the dynamic subject in there. Based upon the code above, what should the value be. I tried {subject} and subject, but just shows up blank in the email.
GreyHead 22 Mar, 2011
Hi dbrody,

Just subject (no brackets or quotes) should do it OK.

Bob
dbrody 22 Mar, 2011
Still no luck, a blank subject. The Dynamic Subject is subject. The code above is in the onsubmit button, the form is linked to a DB with the field subject and it was detached and re-attached. Here is the debug output -

1.Form passed first SPAM check OK
2.Form passed the submissions limit (if enabled) OK
3.Form passed the Image verification (if enabled) OK
4.Form passed the server side validation (if enabled) OK
5.$_POST Array: Array ( [Name] => dave [Address] => test [City] => test [State] => tets [Zip] => test [email] => [email]dave@growhydroponix.com[/email] [radio0] => Store [chrono_verification] => js6lj [button_10] => Submit [9d836a57a6240b9f368e393350eaaba2] => 1 [1cf1] => 090c9ef242c9c8fd8c2efa1d9736e88e [chronoformname] => SampleRequest2a )
6.$_FILES Array: Array ( )
7.Form passed the plugins step (if enabled) OK


From: Hydroponix [dave@growhydroponix.com]
To: [email]dave@growhydroponix.com[/email]
CC:
BCC:
Subject:

Name: dave Address: test City: test State: tets Zip: test Email: [email]dave@growhydroponix.com[/email] IndividualStore: Store Submitted by 68.127.151.212

Files:
GreyHead 22 Mar, 2011
Hi dbrody,

Just checking, the code needs to be in the OnSubmit Before Email box on the Form Code tab; and Send Emails has to be set to 'Yes' on the Form General Tab so that the code is executed.

Bob
dbrody 23 Mar, 2011
Yes to both questions. Any other suggestions?
GreyHead 23 Mar, 2011
Hi dbrody,

By all means email or PM me the site URL and a SuperAdmin login and I'll take a quick look.

Bob
GreyHead 23 Mar, 2011
Hi dbrody,

The problem is the Email verification plug-in which blocks some of the code execution - it's a known bug since Max wrote the plug-in :-(. I've turned it off for the moment and the subject code is working OK. I made one change to the code to get the Name value from the name input (it was radio0 I think).

Bob
dbrody 23 Mar, 2011
I changed it back to email verification since that was more important. Other than that do you think there is a work around or a bug fix coming?
This topic is locked and no more replies can be posted.