How to create more than one form subscribing to Mailchimp?

Home Forums Quform WordPress How to create more than one form subscribing to Mailchimp?

This topic is: not resolved
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #4927
    atomedia
    Participant

    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
    Marek

    #4944
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #4955
    atomedia
    Participant

    I 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);
    }

    #4961
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy