Home › Forums › Quform WordPress › MailChimp Integration – Opt-In Subscribe
- This topic has 11 replies, 2 voices, and was last updated 10 years, 3 months ago by
Ally.
- AuthorPosts
- January 28, 2015 at 9:47 pm #13735
danieltjohnston
ParticipantI have a contact form that I want to add an opt-in checkbox to that will allow the person to join our mailchimp newsletter. Is there a way to integrate MailChimp with this form, so that if the user checks the box to join the newsletter, they are added to our MailChimp list, but if they don’t check the box, they are not added.
January 29, 2015 at 1:11 pm #13749Ally
Support StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
January 30, 2015 at 7:52 pm #13756danieltjohnston
ParticipantThanks for your help. If I wanted to apply this function to multiple forms, all connected to the same mailchimp list, how would I do that?
Thanks again.
February 3, 2015 at 4:23 pm #13764Ally
Support StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
March 12, 2015 at 8:30 pm #14554danieltjohnston
ParticipantHi Ally,
I finally got a chance to test it out, but it doesn’t seem to be working. No matter if I check the box or not, no email address is pushed through to Mailchimp.Here’s the code that I’m using, minus my API and list ID…
function my_save_to_mailchimp_location_opt_in($form)
{
if (!in_array('Join our Newsletter - Sign Up for Additional Resources and Cost Savings Ideas', $form->getValue('iphorm_1_9'))) {
return; }if (!class_exists('MCAPI')) {
require_once dirname(__FILE__) . '/MCAPI.class.php';
}$api = new MCAPI('1111111111111111111'); $listId = '11111111111'; $email = $form->getValue('iphorm_1_5');
// OPTIONAL: if you are saving additional fields to MC, set the merge tags, otherwise set $mergeVars to an empty array
/*$mergeVars = array(
'MERGE1' => $form->getValue('iphorm_3_2'), 'MERGE2' => $form->getValue('iphorm_3_3'), 'MERGE3' => $form->getValue('iphorm_1_5') );
*/
// Other settings
$emailType = 'html';
$doubleOptin = true;
$updateExisting = false;
$replaceInterests = false;
$sendWelcome = false;$api->listSubscribe($listId, $email, $mergeVars, $emailType, $doubleOptin, $updateExisting, $replaceInterests, $sendWelcome);
}
add_action('iphorm_post_process_1', 'my_save_to_mailchimp', 10, 1);March 16, 2015 at 10:13 am #14639Ally
Support StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
March 16, 2015 at 10:14 am #14640Ally
Support StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
March 16, 2015 at 7:08 pm #14652danieltjohnston
ParticipantHi Ally,
I enabled the debug mode logging.Here’s a copy of the log:
http://www.johnstoncompanies.com/debug.logand the page with the form:
http://www.johnstoncompanies.com/locations/joplin/Thanks.
- This reply was modified 10 years, 3 months ago by
danieltjohnston.
March 18, 2015 at 10:31 am #14686Ally
Support StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
March 18, 2015 at 3:54 pm #14703danieltjohnston
ParticipantHi Ally,
I temporarily disabled the sending emails on the Form Builder. Here’s the updated log:http://www.johnstoncompanies.com/debug.log
I attempted the test @ 15:44 of 3/18.
March 18, 2015 at 4:16 pm #14704danieltjohnston
ParticipantHi Ally,
I figured it out, I had failed to update theadd_action('iphorm_post_process_1', 'my_save_to_mailchimp', 10, 1);
to point to the new function name. Once I changed it to this it worked fine.
add_action('iphorm_post_process_1', 'my_save_to_mailchimp_location_opt_in', 10, 1);
Thanks for your help.
March 18, 2015 at 5:20 pm #14705Ally
Support StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
- This reply was modified 10 years, 3 months ago by
- AuthorPosts
- You must be logged in to reply to this topic.