I set up a site on a subdomain...a full implementation of MODx Revolution 2.2.6-pl with Formit set up on the contact us page. I'm also using FormSave. This is a set up I've done successfully many, many times. I also set it up to send a confirmation email to the site visitor, based on a tutorial found here:
http://cipalabs.com/modx/articles/send-a-confirmation-email-with-formit
The problem is that the site visitor is not receiving a confirmation (thank you) email. The hook chain seems to fail on the confirmation hook (a snippet called emailUser-contact) and the page just reloads without redirecting the visitor to the thank you page (the failing confirmation hook stops it from going beyond that point). When I take the emailUser-contact hook out of the list, the submitted form then redirects you to the thank you page properly. The rest of the system works as it should. The problem is just with the confirmation portion.
The only thing I can think of that is different at this point is the fact that this site is running on a subdomain. Can anyone confirm or de-bunk my theory? It could be a too-obvious typo, of course, which I'm failing to see. Thanks in advance.
This is what I have:
The form code looks like this:
[[!FormIt?
&hooks=`spam,FormSave,email,emailUser-contact,redirect`
&submitVar=`contact_page`
&emailSubject=`Submission from The Contact Us Page on the Company, Inc. Website`
&emailTpl=`EmailChunk_contact_page`
&emailTo=`[email protected]`
&redirectTo=`28`
&fsFormTopic=`Contact Page`
&fsFormFields=`firstName-contact,lastName-contact,street_address-contact,city_town-contact,state-contact,zipcode-contact,telephone-contact,email-contact,text-contact`
&validate=`firstName-contact:required,
lastName-contact:required,
street_address-contact:required,
city_town-contact:required,
state-contact:required,
zipcode-contact:required,
telephone-contact:required,
email-contact:required`
]]
[[!+fi.error.error_message:notempty=`
<p>[[!+fi.error.error_message]]</p>
`]]
<form class="form" action="[[~[[*id]]]]" method="post">
<div id="contact_page_form_container">
<h2>Your Information</h2>
<div id="contact_page_form_name">
<input name="nospam:blank" type="hidden" />
<div id="contact_page_form_first_name">
<label for="firstName-contact">
* First Name:
<span class="error">[[+fi.error.firstName-contact]]</span></label>
<input id="firstName-contact" name="firstName-contact" type="text" value="[[+fi.firstName-contact]]" />
</div><!-- /contact_page_form_first_name -->
<div id="contact_page_form_last_name">
<input name="nospam:blank" type="hidden" />
<label for="lastName-contact">
* Last Name:
<span class="error">[[+fi.error.lastName-contact]]</span></label>
<input id="lastName-contact" name="lastName-contact" type="text" value="[[+fi.lastName-contact]]" />
</div><!-- /contact_page_form_last_name -->
<div style="clear: both;"></div>
</div><!-- /contact_page_form_name -->
<div id="contact_page_form_address">
<div id="contact_page_form_street_address">
<label for="street_address-contact">* Street Address:<span class="error">[[+fi.error.street_address-contact]]</span></label><br />
<input name="street_address-contact" type="text" id="street_address-contact" value="[[+fi.street_address-contact]]">
</div><!-- /contact_page_form_street_address -->
<div id="contact_page_form_city_town">
<label for="city_town-contact">* City/Town:<span class="error">[[+fi.error.city_town-contact]]</span></label><br />
<input name="city_town-contact" type="text" id="city_town-contact" value="[[+fi.city_town-contact]]">
</div><!-- /contact_page_form_city_town -->
<div id="contact_page_form_state">
<label for="state-contact">* State:<span class="error">[[+fi.error.state-contact]]</span></label><br />
<div id="state_select_div">
<select name="state-contact" class="select_width">
[[!FormItStateOptions? &selected=`[[!+fi.state-contact]]`]]
</select>
</div><!-- /state_select_div -->
</div><!-- /contact_page_form_state -->
<div id="contact_page_form_zipcode">
<label for="zipcode-contact">* Zipcode:<span class="error">[[+fi.error.zipcode-contact]]</span></label><br />
<input name="zipcode-contact" type="text" id="zipcode-contact" value="[[+fi.zipcode-contact]]">
</div><!-- /contact_page_form_zipcode -->
<div id="contact_page_form_phone_number">
<input name="nospam:blank" type="hidden" />
<label for="telephone-contact">
* Telephone:<span class="error">[[+fi.error.telephone-contact]]</label>
<input id="telephone-contact" name="telephone-contact" type="text" value="[[+fi.telephone-contact]]" />
</div><!-- /contact_page_form_phone_number -->
<div id="contact_page_form_email">
<label for="email-contact">* Email Address:<span class="error">[[+fi.error.email-contact]]</span></label><br />
<input name="email-contact" type="text" id="email-contact" value="[[+fi.email-contact]]">
</div><!-- /contact_page_form_email -->
</div><!-- /contact_page_form_address -->
<div style="clear: both;"></div>
<div id="contact_page_form_comments">
<label for="text-contact">Comments:</label><br />
<textarea name="text-contact" Id="text-contact">[[+fi.text-contact]]</textarea><br>
</div><!-- /contact_page_form_comments -->
<div id="contact_page_form_recaptcha">
this is where the reCaptha code will go.
</div><!-- /contact_page_form_recaptcha -->
<div id="contact_page_form_comments_submit_button">
<input type="hidden" name="subject" id="subject" value="Submission from The Contact Us Page on the Company, Inc. Website" />
<input name="contact_page" class="contact_page_form_submit" title="contact_page" type="submit" value=" ">
</div><!-- /contact_page_form_comments_submit_button -->
</div><!-- /contact_page_form_container -->
</form>
Within the hook chain, the system calls for a snippet called emailUser-contact which contains the following:
<?php
//configuration
$mailFrom = $modx->getOption('emailsender'); //OR USE YOUR OWN;
$mailFromName = $modx->getOption('site_name'); //OR USE YOUR OWN;
$mailSender = $modx->getOption('site_name'); //OR USE YOUR OWN;
$mailSubject = 'Thank You for contacting us through the Company, Inc. website';
$mailReplyTo = $mailFrom;
//get fields values so they can be replaced in the email chunk
$confirmationFields['firstName-contact'] = $scriptProperties['fields']['firstName-contact'];
$confirmationFields['lastName-contact'] = $scriptProperties['fields']['lastName-contact'];
//get user's email
$mailTo= $scriptProperties['fields']['email-contact'];
$text = $modx->getChunk('ConfirmationTpl-contact-page', $confirmationFields);
$modx->getService('mail', 'mail.modPHPMailer');
$modx->mail->set(modMail::MAIL_BODY,$text);
$modx->mail->set(modMail::MAIL_FROM,$mailFrom);
$modx->mail->set(modMail::MAIL_FROM_NAME,$mailFromName);
$modx->mail->set(modMail::MAIL_SENDER,$mailSender);
$modx->mail->set(modMail::MAIL_SUBJECT,$mailSubject);
$modx->mail->address('to',$mailTo);
$modx->mail->address('reply-to',$mailReplyTo);
$modx->mail->setHTML(true);
if (!$modx->mail->send()) {
$modx->log(modX::LOG_LEVEL_ERROR,'An error occurred while trying to send the email: '.$err);
return false;
}
$modx->mail->reset();
return true;
The confirmation tpl, which is called ConfirmationTpl-contact-page (called from within the above snippet) contains this:
<p>Hello,[[+firstName-contact]] [[+lastName-contact]]:</p>
<p>Thank you for contacting us through the Company, Inc. website! We will be getting back to you shortly.</p>
Finally, the tpl that formats the email that the site owner gets (and called from within the Formit call), called EmailChunk_contact_page, contains this:
<br />[[+firstName-contact]] [[+lastName-contact]] ([[+email-contact]]) wrote:<br /><br />
Message: [[+text-contact]]
<br /><br />
First Name: [[+firstName-contact]]<br />
Last Name: [[+lastName-contact]]<br /><br />
Street Address: [[+street_address-contact]]<br />
City/Town: [[+city_town-contact]]<br />
State: [[+state-contact]]<br />
Zipcode: [[+zipcode-contact]]<br />
Phone Number: [[+telephone-contact]]<br />
Email Address: [[+email-contact]]
[ed. note: waizen last edited this post 13 years, 5 months ago.]