User email ID in form submission notification

Permalink
I am trying to display user email id in the form submission notification, and following is my code in block_form_submission.php

<?php
defined('C5_EXECUTE') or die("Access Denied.");

$submittedData='';
foreach($questionAnswerPairs as $questionAnswerPair){
$submittedData .= "<b>".$questionAnswerPair['question']."</b>"." :- ".$questionAnswerPair['answer']."<br/>"."<br/>";
}
$formDisplayUrl=BASE_URL.DIR_REL.'/' . DISPATCHER_FILENAME . '/dashboard/reports/forms/?qsid='.$questionSetId;

$bodyHTML = t("
There has been a payment request submitted by <b><?php echo $uEmail ?></b>.<br/><br/>

%s
<br/>View Full Reports :
%s

", $submittedData, $formDisplayUrl);

But I am not getting user email ID displayed, please advise.

naresh
 
ronyDdeveloper replied on at Permalink Reply
ronyDdeveloper
I think you have to use %s instead of variable in template.
<?php
defined('C5_EXECUTE') or die("Access Denied.");
$submittedData='';
foreach($questionAnswerPairs as $questionAnswerPair){
$submittedData .= "<b>".$questionAnswerPair['question']."</b>"." :- ".$questionAnswerPair['answer']."<br/>"."<br/>";
}
$formDisplayUrl=BASE_URL.DIR_REL.'/' . DISPATCHER_FILENAME . '/dashboard/reports/forms/?qsid='.$questionSetId;
$bodyHTML = t("
There has been a payment request submitted by <b>%s</b>.<br /><br />
%s
<br />View Full Reports :
%s
", $uEmail, $submittedData, $formDisplayUrl);


Rony
naresh replied on at Permalink Reply
naresh
Thanks for replying Rony, I have tried this too, currently what you suggested is what I am using, but still no go..
ronyDdeveloper replied on at Permalink Reply
ronyDdeveloper
Maybe the variable is empty. Try to set any default test value for $uEmail and check whether it is showing or not. If yes, then you have to check, how to pass the email to template.

Rony
naresh replied on at Permalink Reply
naresh
I am novice to PHP, not sure what you mean :(
ronyDdeveloper replied on at Permalink Reply
ronyDdeveloper
No problem, put the below code and check whether its showing the email or not.
<?php
defined('C5_EXECUTE') or die("Access Denied.");
$submittedData='';
$uEmail = 'do-not-reply@test.com';
foreach($questionAnswerPairs as $questionAnswerPair){
$submittedData .= "<b>".$questionAnswerPair['question']."</b>"." :- ".$questionAnswerPair['answer']."<br/>"."<br/>";
}
$formDisplayUrl=BASE_URL.DIR_REL.'/' . DISPATCHER_FILENAME . '/dashboard/reports/forms/?qsid='.$questionSetId;
$bodyHTML = t("
There has been a payment request submitted by <b>%s</b>.<br /><br />
%s
<br />View Full Reports :
%s
", $uEmail, $submittedData, $formDisplayUrl);


From the above code I've set $uEmail = 'do-not-reply@test.com'; so it will be shown in your email. If its working then let me know. I'll explain you next step.

Rony
naresh replied on at Permalink Reply
naresh
Hi rony, did that now getting this error on submission..

Parse error: syntax error, unexpected T_FOREACH in aaaa.co.in/mail/block_form_submission.php on line 6
I think now in foreach we need to define something
naresh replied on at Permalink Reply
naresh
Sorry I had done something wrong rony, yes now i get the value which is there in $uEail='' that is do-not-reply@test.com
mhawke replied on at Permalink Reply
mhawke
Another silly question: Are you logging in as the 'user' or are you logging in as yourself (the admin)?
naresh replied on at Permalink Reply
naresh
logging as user
mhawke replied on at Permalink Reply
mhawke
Silly question but this form is only available after a user has logged in, correct?
naresh replied on at Permalink Reply
naresh
Yes you are right, sorry i missed to mention that..