Multiple Form with check validation and Mailchimp integration

Home Forums Quform WordPress Multiple Form with check validation and Mailchimp integration

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

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

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

    • This reply was modified 8 years, 11 months ago by Ally. Reason: Fixed error
    #15401
    lucasaguiar
    Participant

    Still 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
    #15412
    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