Check out the LimeSurvey source code on GitHub!

Token information in survey response email

More
6 years 3 weeks ago #55765 by waitz
Is there a way I can add a token in the subject field of the email that goes to the administrator when someone has submitted a survey?

I see that the subject is created in line 1856 in index.php, and it didn't work just to add {TOKEN:FIRSTNAME}

The admin notification is set to "Basic email notification".

Version 1.91+ Build 11232 | PHP 5.3.9 | MySQL 5.1.56 |

Please Log in to join the conversation.

More
6 years 3 weeks ago - 6 years 3 weeks ago #55769 by Mazi
You probably need to run some replacement function at this part of the code because Limesurvey only replaces such fields if you tell it to do so.
//get additional attributes for this survey
$attrfieldnames=GetTokenFieldsAndNames($surveyid);
 
//array containing [searchstring] = $replacestring
$attrreplacearray = array();
 
//check each available additional attribute
foreach($attrfieldnames as $attid => $attname)
{
//search for this key
$key = "{TOKEN:".strtoupper($attid)."}";
 
//add replacement value
$attrreplacearray[$key]=$answerdataarray[$attid];										
}
//replace attributes at every answer
$emailsubject = Replacefields($emailsubject , $attrreplacearray);
This code is not tested and you need to find out where to get the answer data from.


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"
Last Edit: 6 years 3 weeks ago by Mazi.

Please Log in to join the conversation.

More
6 years 3 weeks ago - 6 years 3 weeks ago #55815 by waitz
I tried to enter the code above before the line
$subject = sprintf($clang->gT("Response submission for survey %s","unescaped"), $thissurvey['name']);
But I got a huge error after survey submit...

Version 1.91+ Build 11232 | PHP 5.3.9 | MySQL 5.1.56 |
Last Edit: 6 years 3 weeks ago by waitz.

Please Log in to join the conversation.

More
6 years 3 weeks ago #55852 by Mazi

waitz wrote: I tried to enter the code above before the line

$subject = sprintf($clang->gT("Response submission for survey %s","unescaped"), $thissurvey['name']);
But I got a huge error after survey submit...

Postingt he error message might help a lot to solve this :-)


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"

Please Log in to join the conversation.

More
6 years 3 weeks ago - 6 years 3 weeks ago #55860 by waitz
Oops, I was a bit thought less. The error is:
Notice: Undefined variable: emailsubject in /home/humanive/public_html/registration/index.php on line 1872
 
Warning: Cannot modify header information - headers already sent by (output started at /home/.../limesurvey/index.php:1872) in /home/.../limesurvey/common.php on line 5098
Line 1872 in index.php is the line with:
$emailsubject = Replacefields($emailsubject , $attrreplacearray);
Line 5098 in common.php is the last line of these:
// Delete the Session Cookie
    $CookieInfo = session_get_cookie_params();
    if ( (empty($CookieInfo['domain'])) && (empty($CookieInfo['secure'])) ) {
        setcookie(session_name(), '', time()-3600, $CookieInfo['path']);

Version 1.91+ Build 11232 | PHP 5.3.9 | MySQL 5.1.56 |
Last Edit: 6 years 3 weeks ago by waitz.

Please Log in to join the conversation.

Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form