[[!FormIt? emailTo=`[[+emailRecipient]]`]]
$hook->setValue('emailRecipient', '[email protected]');
$email_recipient = $hook->getValue('emailRecipient');
error_log($email_recipient);
// returns [email protected]
$hook->setValue('emailRecipient', '[email protected],[email protected]');
$email_recipient = $hook->getValue('emailRecipient');
error_log($email_recipient);
// returns [email protected],[email protected]
(ERROR @ mysite.com/core/components/formit/model/formit/fihooks.class.php : 552) [FormIt] An error occurred while trying to send the email. You must provide at least one recipient email address.
[[!FormIt? &emailTo=`[email protected],[email protected]`]]
$hook->formit->options['emailTo'] = '[email protected],[email protected]';
Try to modify the formit property directly in the hook:I've tried this and I'm still getting the same result.
$hook->formit->options['emailTo'] = '[email protected],[email protected]';
This is a known problem with FormIt. You can use the &emailCC or &emailBCC properties as a workaround. I think they will take a comma-separated list but I'm not positive.Unfortunately the client would like the emailTo parameter to be both email addresses.
Quote from: Jako at Oct 18, 2016, 11:58 PMTry to modify the formit property directly in the hook:I've tried this and I'm still getting the same result.
$hook->formit->options['emailTo'] = '[email protected],[email protected]';
Quote from: jmbuytaert at Oct 19, 2016, 06:35 PMI agree, this should absolutely work, but I'm still not being redirected to the thank you form, and I'm still not receiving the emails. He is my code below:Quote from: Jako at Oct 18, 2016, 11:58 PMTry to modify the formit property directly in the hook:I've tried this and I'm still getting the same result.
$hook->formit->options['emailTo'] = '[email protected],[email protected]';
This should work absolutely the same as adding the value to the snippet options. I think you have an issue in the hooks then. The email hook has to run after your custom hook that sets the emailTo.
<?php
error_log("hook1: ".$hook->formit->options['emailTo']);
// Pull Division and Region selected from Form
$np_msds = $hook->getValue('request-msds');
// Get email address based whether or not SDS checkbox is selected
if($np_msds == "yes"){
$hook->formit->options['emailTo'] = "[email protected],[email protected]";
error_log("hook form1: ".$hook->formit->options['emailTo']);
} else {
$hook->formit->options['emailTo'] = "[email protected]";
error_log("hook form2: ".$hook->formit->options['emailTo']);
}
error_log("hook last: ".$hook->formit->options['emailTo']);
error_log("******************** SNIPPET ENDS");
return true;
[[!FormIt? ... &hooks=`mySnippet,email`]]
******************** SNIPPET BEGINS, referer: http://mysite.com/page.html hook1: , referer: http://mysite.com/page.html hook form1: [email protected],[email protected], referer: http://mysite.com/page.html hook last: [email protected],[email protected], referer: http://mysite.com/page.html ******************** SNIPPET ENDS, referer: http://mysite.com/page.html
[2016-10-20 16:15:11] (ERROR @ /var/www/vhosts/mysite.com/core/components/formit/model/formit/fihooks.class.php : 379) [FormIt] Please specify a recipient or recipients for the email.
<?php
$path = MODX_CORE_PATH . 'components/opc_database/';
$result = $modx->addPackage('opc_database',$path . 'model/','');
if (! $result) {
return 'failed to add package';
} else {
$pe = $_GET["pe"];
$opc_ID = trim($pe);
// $opc_ID = 11;
$opc = $modx->getObject('Person', array('PKPersonId' => $opc_ID));
$emd = $opc->get('PersonEmailDomain');
$emp = $opc->get('PersonEmail');
//
$opc_em = $emp."@".$emd;
$spf_opc = "OPC: ".$opc_em;
//
$emto = trim($opc_em);
$modx->setPlaceholder('addressTo',$emto);
$modx->setPlaceholder('opc_addressTo',$spf_opc);
$hook->formit->options['emailTo'] = $emto;
}
return true;
[!FormIt?
$prehooks = `load-opc_em`
&hooks=`email,redirect`
&emailTpl=`MyTestEmailChunk`
&emailSubject=`Website Query`
&redirectTo=`81`
]]
<h2>Contact Form</h2><div class="well">
<form action="[[~[[*id]]]]" method="post">
<input type="text" name="opcname" value="[[+opcname]] [[!+fi.opcname]]" class="input-block-level">
<div id="name">
<label for="name">Name:</label>
<div class="controls">
<input type="text" name="name" value="[[!+fi.name]]" class="input-block-level">
</div>
</div>
<div id="email">
<label for="email">Email:</label>
<div class="controls">
<input type="text" name="email" value="[[!+fi.email]]" class="input-block-level">
</div>
</div>
<div id="comment">
<label for="comment">Comment:</label>
<div class="controls">
<textarea name="comment" cols="30" rows="10" value="[[!+fi.comment]]" class="input-block-level"></textarea>
</div>
</div>
<input type="submit" value="Submit" class="btn btn-primary">
</form>
</div>This is a known problem with FormIt. You can use the &emailCC or &emailBCC properties as a workaround. I think they will take a comma-separated list but I'm not positive.