Home › Forums › Quform WordPress › integration of multiple forms with MailChimp
- This topic has 4 replies, 2 voices, and was last updated 8 years, 10 months ago by Ally.
- AuthorPosts
- December 2, 2014 at 1:01 am #13241aucuttdesignParticipant
I used your mailchimp integration guidelines to make my quform data that is submitted also populate one of my MailChimp lists. I have multiple lists and multiple forms I would like to do the same on the same site. How do I get more than one list to work?
December 2, 2014 at 5:56 am #13242aucuttdesignParticipantI was reading another forum response to collecting data from multiple forms which I wonder if that technique would work with multiple MailChimp lists? One problem I see right away is that there are two MERGE0 array values, one for each form’s email address. Can you look at the code below and see if this would work?
// mailchimp and qform integration
function my_save_to_mailchimp($form)
{
if (!class_exists(‘MCAPI’)) {
require_once dirname(__FILE__) . ‘/MCAPI.class.php’;
}$api = new MCAPI(‘my api address’);
switch($form->$listId()) {
case 1:
$listID = ‘list id 1’;
break;
case 2:
$listId = ‘list id 2’;
break:
}
switch($form->getId()) {
case 1:
$email = $form->getValue(‘iphorm_1_1’);
break;
case 2:
$email = $form->getValue(‘iphorm_2_1’);
break;
}// OPTIONAL: if you are saving additional fields to MC, set the merge tags, otherwise set $mergeVars to an empty array
$mergeVars = array(
‘MERGE0’ => $form->getValue(‘iphorm_1_1’),
‘MERGE1’ => $form->getValue(‘iphorm_1_3’),
‘MERGE2’ => $form->getValue(‘iphorm_1_4’),
‘MERGE0’ => $form->getValue(‘iphorm_2_1’),
‘FNAME’ => $form->getValue(‘iphorm_2_3’),
‘REASON’ => $form->getValue(‘iphorm_2_5’)
);// Other settings
$emailType = ‘html’;
$doubleOptin = false;
$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);
add_action(‘iphorm_post_process_2’, ‘my_save_to_mailchimp’, 10, 1);December 9, 2014 at 1:17 pm #13308AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
July 1, 2015 at 9:26 pm #15783aucuttdesignParticipantI know it has been a long time since I replied to this but I didn’t get it to work and we chose to simply forego the mailchimp integration. Now they want it working again. I followed all of the steps you laid out above and I’m including the code I added to the functions.php file below.
Here is what is happening. When I input data into the form (I am using Google Chrome as a browser) I get an error message – from the browser, not the site – saying “An error occurred submitting the form.” The data is stored on the site in the quform entries just fine and acknowledgement emails get sent from the site fine but the data does not go to MailChimp. I have double checked the api key and the list ids and everything else required in the functions area. I don’t understand what is going wrong.
You will notice in the coding below that I include the full link to the MCAPI.class.php file. The reason I did this is because I am using a child theme and wanted to make sure that was pointed to the right directory.
Please help if you can. Thank you.
Scott Aucutt
// mailchimp and qform integration
function my_save_to_mailchimp($form)
{
if (!class_exists(‘MCAPI’)) {
require_once dirname(__FILE__) . ‘http://utahdinebikeyah.org/wp-content/themes/fairview/MCAPI.class.php’;
}$api = new MCAPI(‘MYAPI’);
switch($form->getId()) {
case 1:
$listID = ‘0a1bb33036’;
$email = $form->getValue(‘iphorm_1_1’);
$mergeVars = array(
‘MERGE0’ => $form->getValue(‘iphorm_1_1’),
‘MERGE1’ => $form->getValue(‘iphorm_1_3’),
‘MERGE2’ => $form->getValue(‘iphorm_1_4’)
);
break;
case 2:
$listId = ‘9a991825e3’;
$email = $form->getValue(‘iphorm_2_1’);
$mergeVars = array(
‘EMAIL’ => $form->getValue(‘iphorm_2_1’),
‘FNAME’ => $form->getValue(‘iphorm_2_3’),
‘REASON’ => $form->getValue(‘iphorm_2_5’)
);
break;
}// Other settings
$emailType = ‘html’;
$doubleOptin = false;
$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);
add_action(‘iphorm_post_process_2’, ‘my_save_to_mailchimp’, 10, 1);Attachments:
You must be logged in to view attached files.July 6, 2015 at 4:50 pm #15905AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
- AuthorPosts
- You must be logged in to reply to this topic.