integration of multiple forms with MailChimp

Home Forums Quform WordPress integration of multiple forms with MailChimp

This topic is: not resolved
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #13241
    aucuttdesign
    Participant

    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?

    #13242
    aucuttdesign
    Participant

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

    #13308
    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.

    #15783
    aucuttdesign
    Participant

    I 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.
    #15905
    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 5 posts - 1 through 5 (of 5 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