Forum Replies Created
- AuthorPosts
- June 21, 2013 at 12:39 pm in reply to: How to create more than one form subscribing to Mailchimp? #4955
atomedia
ParticipantI 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);
}
atomedia
ParticipantIt works, you’re great! Thanks a lot! 🙂
atomedia
ParticipantSorry Ally, my mistake! The fields are not Multiple Choice, they are both Checkboxes!
I have changed one of them to Multiple Choice and then everything works.
Unfortunately, I need Checkboxes, so the problem still exists.
Regards
Marekatomedia
ParticipantI’ve double checked and the names of the groups are exactly the same as in Mailchimp. I’ve replaced $form->getValue(‘iphorm_1_4′) with one of the options (‘Sklep stacjonarny’) and then it works.
Best
Marekatomedia
Participant$mergeVars = array(
'MERGE1' => $form->getValue('iphorm_1_1'),
'MERGE2' => $form->getValue('iphorm_1_2'),
'GROUPINGS' => array(
array('name' => 'Jaka firme reprezentujesz?', 'groups' => $form->getValue('iphorm_1_4')),
array('name' => 'Jaki asortyment Cie interesuje?', 'groups' => $form->getValue('iphorm_1_6')),
array('name' => 'Ktory biuletyn chcesz dostawac?', 'groups' => 'Darmowe raporty i e-booki (nieregularnie)')
)
);The 3rd grouping (Ktory biuletyn chcesz dostawac) works fine, but the previous two – don’t.
Both iphorm_1_4 and iphorm_1_6 are Multiple Choice fields.
I hope you’ll be able help me 🙂Best regards
Marekatomedia
ParticipantNow it’s clear for me, thank you! Everything works except choosing the groups. The subscriber is added to Mailchimp, but with no groups selected. Maybe I should change other settings?
$emailType = 'html';
$doubleOptin = false;
$updateExisting = false;
$replaceInterests = false;
$sendWelcome = false;
Best
Marekatomedia
ParticipantHi Ally,
Could you please explain – what do you mean saying “name of the group” and “list of groups”? Actual names (descriptive), names from the source code or IDs? Where to find these parameters?
What if I want to let the subscribers choose the groups by themselves using multiple choice field?
Best regards,
Marek - AuthorPosts