Home › Forums › Quform WordPress › How to create more than one form subscribing to Mailchimp?
- This topic has 3 replies, 2 voices, and was last updated 11 years, 5 months ago by Ally.
- AuthorPosts
- June 20, 2013 at 10:54 am #4927atomediaParticipant
Hi TC,
I have created a form adding subscribers to Mailchimp according to your guide and it works fine. What should I do to create another form, also subscribing people to Mailchimp, but to different groups? It doesn’t work if I just duplicate the code in functions.php and change unique fields IDs.
Best regards
MarekJune 21, 2013 at 10:04 am #4944AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
June 21, 2013 at 12:39 pm #4955atomediaParticipantI have no idea why, but it doesn’t work. Please look at the code of the second function below (I’ve replaced API key and list ID with XXX).
add_action('iphorm_post_process_2', 'mytheme_save_to_mailchimp2', 10, 1);function mytheme_save_to_mailchimp2($form)
{
require_once dirname(__FILE__) . '/MCAPI.class.php';$api = new MCAPI('XXX');
$listId = 'XXX';
$email = $form->getValue('iphorm_2_3');// 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_2_1'),
'MERGE2' => $form->getValue('iphorm_2_2'),
'GROUPINGS' => array(
array('name' => 'Jaką firmę reprezentujesz?', 'groups' => join(',', $form->getValue('iphorm_2_12'))),
array('name' => 'Jaki asortyment Cię interesuje?', 'groups' => join(',', $form->getValue('iphorm_2_6'))),
array('name' => 'Który biuletyn chcesz dostawać?', 'groups' => 'Wiadomości z branży zabawek i art. dziecięcych (co tydzień)')
)
);// Other settings
$emailType = 'html';
$doubleOptin = true;
$updateExisting = false;
$replaceInterests = false;
$sendWelcome = false;$api->listSubscribe($listId, $email, $mergeVars, $emailType, $doubleOptin, $updateExisting, $replaceInterests, $sendWelcome);
}
June 21, 2013 at 2:11 pm #4961AllySupport 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.