Home › Forums › Quform WordPress › Multiple Form with check validation and Mailchimp integration
- This topic has 3 replies, 2 voices, and was last updated 8 years, 11 months ago by Ally.
- AuthorPosts
- May 18, 2015 at 1:44 am #15320lucasaguiarParticipant
Hi,
I try to use these code, but isn’t working.
They are 3 different Quform with a question if the user wanna subscribe the newsletter each.
function my_save_to_mailchimp($form)
{
if (!in_array('Gostaria de receber e-mails com as novidades da Simex.', $form->getValue('iphorm_1_13')) && !in_array('I would like to receive e-mails with news of Simex.', $form->getValue('iphorm_2_13')) && !in_array('Me gustaría recibir correos electrónicos con noticias de Simex.', $form->getValue('iphorm_3_13'))) {
return; }if (!class_exists('MCAPI')) {
require_once dirname(__FILE__) . '/MCAPI.class.php';
}$api = new MCAPI('37100201b07adaf2ad72530e44dc0461-us10');
switch($form->getId()) {
// Brasil
case 1:
$listID = 'f762a1d71c';
$email = $form->getValue('iphorm_1_8');
$mergeVars = array(
'FNAME' => $form->getValue('iphorm_1_3'),
'LNAME' => $form->getValue('iphorm_1_4')
);
break;
// EUA
case 2:
$listID = '9b3a166246';
$email = $form->getValue('iphorm_2_8');
$mergeVars = array(
'FNAME' => $form->getValue('iphorm_2_3'),
'LNAME' => $form->getValue('iphorm_2_4')
);
break;
// Espanha
case 3:
$listID = '91f0f9edd4';
$email = $form->getValue('iphorm_3_8');
$mergeVars = array(
'FNAME' => $form->getValue('iphorm_3_3'),
'LNAME' => $form->getValue('iphorm_3_4')
);
break;
}// Outras configs
$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);
add_action('iphorm_post_process_3', 'my_save_to_mailchimp', 10, 1);
May 20, 2015 at 9:08 am #15333AllySupport 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 8 years, 11 months ago by Ally. Reason: Fixed error
May 29, 2015 at 1:48 am #15401lucasaguiarParticipantStill not working…
Look the entire code:
function my_save_to_mailchimp($form)
{
if (
($form->getId() == 1 && !in_array('Gostaria de receber e-mails com as novidades da Simex.', $form->getValue('iphorm_1_13'))) ||
($form->getId() == 4 && !in_array('I would like to receive e-mails with news of Simex.', $form->getValue('iphorm_4_13'))) ||
($form->getId() == 5 && !in_array('Me gustaría recibir correos electrónicos con noticias de Simex.', $form->getValue('iphorm_5_13')))
) {
return;
}if (!class_exists('MCAPI')) {
require_once dirname(__FILE__) . '/MCAPI.class.php';
}$api = new MCAPI('*SNIP - TC*');
switch($form->getId()) {
// Brasil
case 1:
$listID = '*SNIP - TC*';
$email = $form->getValue('iphorm_1_8');
$mergeVars = array(
'FNAME' => $form->getValue('iphorm_1_3'),
'LNAME' => $form->getValue('iphorm_1_4')
);
break;
// EUA
case 4:
$listID = '*SNIP - TC*';
$email = $form->getValue('iphorm_4_8');
$mergeVars = array(
'FNAME' => $form->getValue('iphorm_4_3'),
'LNAME' => $form->getValue('iphorm_4_4')
);
break;
// Espanha
case 5:
$listID = '*SNIP - TC*';
$email = $form->getValue('iphorm_5_8');
$mergeVars = array(
'FNAME' => $form->getValue('iphorm_5_3'),
'LNAME' => $form->getValue('iphorm_5_4')
);
break;
}// Outras configs
$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_4', 'my_save_to_mailchimp', 10, 1);
add_action('iphorm_post_process_5', 'my_save_to_mailchimp', 10, 1);
- This reply was modified 8 years, 11 months ago by Ally. Reason: Removed API key
June 1, 2015 at 12:04 pm #15412AllySupport 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.