Forum

Thread tagged as: MailChimp

MailChimp / Forms App double-duty and optional opt-in

I'm using the Forms App for a simple contact form. I'd like to add a checkbox which, if checked, submits the form not only to the Forms App, but also adds the email field to the client's MailChimp list. The Forms App and MailChimp apps are installed, setup and running smoothly. I'm following the double-duty subscribe and contact form example in the docs, but I don't see any options in the docs or forums about how to make an opt-in to the MailChimp list optional for an end-user. Is that possible?

Thanks!

Franz Neumann

Franz Neumann 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Use mailer="confirm_subscribe" like this:

<perch:input type="checkbox" value="1" id="confirm" mailer="confirm_subscribe" />

Thanks Drew. The form submits successfully to the Forms App, but not to the Mailchimp app or the Mailchimp website, where the entry isn't added. I can't find what I'm doing wrong in the code.

Here's my form (with all the Foundation layout code stripped out for easier reading).

<perch:form id="contact" app="perch_mailchimp perch_forms" double-optin="false" send-welcome="false">

<perch:content id="intro" type="textarea" label="Form introduction" size="xs" editor="redactor" html="true" size="m" divider-before="Contact Form" />

<perch:error for="name" type="required">Please add your name</perch:error> <perch:input type="text" id="name" required="true" label="Name" placeholder="Your Name" mailer="NAME" />

<perch:error for="email" type="required">Please add your email address</perch:error> <perch:input type="text" id="email" required="true" label="Email" placeholder="Your Email" mailer="EMAIL" />

<perch:error for="phone" type="required">Please add your phone number</perch:error> <perch:input type="text" id="phone" required="true" label="Phone" placeholder="Your Phone" mailer="PHONE" />

<perch:error for="zip" type="required">Please add your zip code</perch:error> <perch:input type="text" id="zip" required="true" label="Zip Code" placeholder="Your Zip Code" mailer="ZIP" />

<perch:error for="subject" type="required">Please choose your subject</perch:error> <perch:input type="select" id="subject" options="Choose your subject...,Where to Buy, Product Usage, Interest in Selling Kellogg and/or G&B Organic Products, Rebates, Other" />

<perch:error for="message" type="required">Please add a message</perch:error> <perch:input type="textarea" id="message" required="true" label="Message" placeholder="Your Message" />

<perch:error for="message" type="required">Join our mailing list?</perch:error> <perch:input type="checkbox" value="1" id="confirm" mailer="confirm_subscribe" /> Would you like to join our mailing list?

                <div style="display:none;">
                    <perch:input type="text" id="chaff" antispam="honeypot" label="Leave this field blank." />
                </div>

                <div>
                    <perch:input type="submit" id="submit" value="Send" />
                </div>

                <perch:success>
                    <perch:content id="success" type="textarea" label="Thank you message" html="true" editor="redactor" size="m" />
                </perch:success>
        </perch:form>
Drew McLellan

Drew McLellan 2638 points
Perch Support

That looks like it should work. If you add debug to the page and submit the form, what does it output?

So if I visit the page with the form the debug on, I see this:

Debug Message
SELECT * FROM perch2_pages WHERE pagePath='/contact/index.php' LIMIT 1
Using template: /templates/pages/attributes/default.html
Using sub-template: /templates/pages/attributes/seo.html
Using template: /templates/pages/attributes/default.html
Using sub-template: /templates/pages/attributes/seo.html
SELECT regionKey, regionHTML FROM perch2_content_regions WHERE regionPage='/contact/index.php' OR regionPage='*' ORDER BY regionPage DESC

If I submit the form on the page I see this:
SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=0
SELECT * FROM perch2_forms WHERE formKey='contact' LIMIT 1
SELECT * FROM perch2_pages WHERE pagePath='/contact/' LIMIT 1
Checking Akismet for spam
Message is not spam
Message sent!
INSERT INTO perch2_forms_responses(responseJSON,formID,responseIP,responseSpamData) VALUES('{\"fields\":{\"name\":{\"attributes\":{\"type\":\"text\",\"id\":\"name\",\"required\":\"true\",\"label\":\"Name\",\"placeholder\":\"Your Name\",\"mailer\":\"NAME\"},\"value\":\"Franz Test 3\"},\"email\":{\"attributes\":{\"type\":\"text\",\"id\":\"email\",\"required\":\"true\",\"label\":\"Email\",\"placeholder\":\"Your Email\",\"mailer\":\"EMAIL\"},\"value\":\"franz3@copyanddesign.com\"},\"phone\":{\"attributes\":{\"type\":\"text\",\"id\":\"phone\",\"required\":\"true\",\"label\":\"Phone\",\"placeholder\":\"Your Phone\",\"mailer\":\"PHONE\"},\"value\":\"111-222-3333\"},\"zip\":{\"attributes\":{\"type\":\"text\",\"id\":\"zip\",\"required\":\"true\",\"label\":\"Zip Code\",\"placeholder\":\"Your Zip Code\",\"mailer\":\"ZIP\"},\"value\":\"90807\"},\"subject\":{\"attributes\":{\"type\":\"select\",\"id\":\"subject\",\"options\":\"Choose your subject...,Where to Buy, Product Usage, Interest in Selling Kellogg and\\/or G&B Organic Products, Rebates, Other\"},\"value\":\"Other\"},\"message\":{\"attributes\":{\"type\":\"textarea\",\"id\":\"message\",\"required\":\"true\",\"label\":\"Message\",\"placeholder\":\"Your Message\"},\"value\":\"Debug on, checked for opt-in\"},\"confirm\":{\"attributes\":{\"type\":\"checkbox\",\"value\":\"1\",\"id\":\"confirm\",\"mailer\":\"confirm_subscribe\"},\"value\":\"1\"}},\"files\":[],\"page\":\"\\/contact\\/\"}','1','71.189.216.125','{\"fields\":{\"honeypot\":\"\"},\"environment\":{\"PATH\":\"\\/sbin:\\/usr\\/sbin:\\/bin:\\/usr\\/bin\",\"PP_CUSTOM_PHP_INI\":\"\\/var\\/www\\/vhosts\\/system\\/kellogggarden.com\\/etc\\/php.ini\",\"PP_CUSTOM_PHP_CGI_INDEX\":\"fastcgi\",\"SCRIPT_NAME\":\"\\/contact\\/index.php\",\"REQUEST_URI\":\"\\/contact\\/\",\"QUERY_STRING\":\"\",\"REQUEST_METHOD\":\"POST\",\"SERVER_PROTOCOL\":\"HTTP\\/1.0\",\"GATEWAY_INTERFACE\":\"CGI\\/1.1\",\"REMOTE_PORT\":\"42427\",\"SCRIPT_FILENAME\":\"\\/var\\/www\\/vhosts\\/kellogggarden.com\\/httpdocs\\/contact\\/index.php\",\"SERVER_ADMIN\":\"root@y6vk-hs8n.accessdomain.com\",\"DOCUMENT_ROOT\":\"\\/var\\/www\\/vhosts\\/kellogggarden.com\\/httpdocs\",\"REMOTE_ADDR\":\"71.189.216.125\",\"SERVER_PORT\":\"80\",\"SERVER_ADDR\":\"72.47.233.152\",\"SERVER_NAME\":\"y6vk-hs8n.accessdomain.com\",\"SERVER_SOFTWARE\":\"Apache\",\"SERVER_SIGNATURE\":\"<address>Apache Server at y6vk-hs8n.accessdomain.com Port 80<\\/address>\\n\",\"HTTP_COOKIE\":\"cmsa=1; PHPSESSID=u8kskue3jiaf1k1sb5hflp40r0; __unam=3210271-14c902a4384-3d88c8c8-25; _ga=GA1.2.674700413.1428347830; _gat=1\",\"HTTP_DNT\":\"1\",\"HTTP_REFERER\":\"https:\\/\\/y6vk-hs8n.accessdomain.com\\/contact\\/\",\"HTTP_USER_AGENT\":\"Mozilla\\/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit\\/600.4.10 (KHTML, like Gecko) Version\\/8.0.4 Safari\\/600.4.10\",\"HTTP_ORIGIN\":\"https:\\/\\/y6vk-hs8n.accessdomain.com\",\"CONTENT_TYPE\":\"application\\/x-www-form-urlencoded\",\"HTTP_ACCEPT_LANGUAGE\":\"en-us\",\"HTTP_ACCEPT_ENCODING\":\"gzip, deflate\",\"HTTP_ACCEPT\":\"text\\/html,application\\/xhtml+xml,application\\/xml;q=0.9,*\\/*;q=0.8\",\"CONTENT_LENGTH\":\"267\",\"HTTP_CONNECTION\":\"close\",\"HTTP_X_ACCEL_INTERNAL\":\"\\/internal-nginx-static-location\",\"HTTP_X_FORWARDED_FOR\":\"71.189.216.125\",\"HTTP_X_REAL_IP\":\"71.189.216.125\",\"HTTP_HOST\":\"y6vk-hs8n.accessdomain.com\",\"UNIQUE_ID\":\"VSVzb0gv6ZgAADrdFIYAAAAB\",\"FCGI_ROLE\":\"RESPONDER\",\"PHP_SELF\":\"\\/contact\\/index.php\",\"REQUEST_TIME_FLOAT\":1428517743.5198,\"REQUEST_TIME\":1428517743}}')
SELECT * FROM perch2_forms_responses WHERE responseID='91' LIMIT 1
Logging resources for
No ids to log.
SELECT * FROM perch2_pages WHERE pagePath='/contact/index.php' LIMIT 1
Using template: /templates/pages/attributes/default.html
Using sub-template: /templates/pages/attributes/seo.html
Using template: /templates/pages/attributes/default.html
Using sub-template: /templates/pages/attributes/seo.html
SELECT regionKey, regionHTML FROM perch2_content_regions WHERE regionPage='/contact/index.php' OR regionPage='*' ORDER BY regionPage DESC
Array
(
    [type] => 8
    [message] => Trying to get property of non-object
    [file] => /var/www/vhosts/kellogggarden.com/httpdocs/perch/core/lib/api/PerchAPI_Base.class.php
    [line] => 19
)
Drew McLellan

Drew McLellan 2638 points
Perch Support

Is this Perch 2.8.4?

Perch 2.8.2.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Does the issue persist with the current version?