Welcome, Guest
Username: Password: Remember me

TOPIC: Token information in survey response email

Token information in survey response email 3 years 7 months ago #55765

  • waitz
  • waitz's Avatar
  • OFFLINE
  • Gold Lime
  • Posts: 171
  • Thank you received: 1
  • Karma: 3
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 |
The administrator has disabled public write access.

Re: Token information in survey response email 3 years 7 months ago #55769

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5324
  • Thank you received: 294
  • Karma: 249
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)limesurvey.org'"
Last Edit: 3 years 7 months ago by Mazi.
The administrator has disabled public write access.

Re: Token information in survey response email 3 years 7 months ago #55815

  • waitz
  • waitz's Avatar
  • OFFLINE
  • Gold Lime
  • Posts: 171
  • Thank you received: 1
  • Karma: 3
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: 3 years 7 months ago by waitz.
The administrator has disabled public write access.

Re: Token information in survey response email 3 years 7 months ago #55852

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5324
  • Thank you received: 294
  • Karma: 249
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)limesurvey.org'"
The administrator has disabled public write access.

Re: Token information in survey response email 3 years 7 months ago #55860

  • waitz
  • waitz's Avatar
  • OFFLINE
  • Gold Lime
  • Posts: 171
  • Thank you received: 1
  • Karma: 3
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: 3 years 7 months ago by waitz.
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.429 seconds
Donation Image