Getting Error Popup on Form Submission

Home Forums Quform WordPress Getting Error Popup on Form Submission

This topic is: not resolved
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #13766
    clydesanchez32
    Participant

    Hi Ally, I am having a bit of trouble getting my Mailchimp newsletter signup form to submit. I’m getting a popup error stating, “An error occurred submitting the form”

    I have some custom code in my functions.php file you gave me in a previous support request, you can find that below:


    // QUFORM --> MAILCHIMP INTEGRATION
    add_action('iphorm_post_process_3', 'mytheme_save_to_mailchimp', 10, 1);

    function mytheme_save_to_mailchimp($form)
    {
    require_once dirname(__FILE__) . '/MCAPI.class.php';

    $api = new MCAPI('*SNIP - TC*');
    $listId = '*SNIP - TC*';
    $email = $form->getValue('iphorm_3_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_3_1'),
    'MERGE2' => $form->getValue('iphorm_3_2')
    );

    // Other settings
    $emailType = 'html';
    $doubleOptin = true;
    $updateExisting = false;
    $replaceInterests = false;
    $sendWelcome = true;

    $api->listSubscribe($listId, $email, $mergeVars, $emailType, $doubleOptin, $updateExisting, $replaceInterests, $sendWelcome);
    }

    function my_check_mailchimp_subscribed($valid, $value, $element)
    {
    // Only perform the lookup if previous validators have passed
    if ($valid) {
    require_once dirname(__FILE__) . '/MCAPI.class.php';

    $api = new MCAPI('*SNIP - TC*');
    $listId = '*SNIP - TC*';

    $response = $api->listMemberInfo($listId, $value);

    if ($api->errorCode) {
    // API ERROR - Log errors to PHP error log, but allow the form to submit
    iphorm_error_log('Unable to load listMemberInfo()!', $api->errorCode, $api->errorMessage);
    } else {
    if (isset($response['success']) && $response['success'] > 0) {
    $element->addError('This email is already registered');
    $valid = false;
    }
    }
    }

    return $valid;
    }
    add_action('iphorm_element_valid_iphorm_3_3', 'my_check_mailchimp_subscribed', 10, 3)

    I removed the code in my functions.php file and tested my form and the form was submitted. It even add the info inside the form database. BUT, the user didn’t receive an email with link to opt-in. I tried to figure it out myself, but just can’t…

    To test yourself, just go to http://www.craftsbycourtney.com/newsletter/ and try signing up. You’ll receive the popup error if you enter the email address field.

    Please help!

    Regards,

    Clyde

    • This topic was modified 9 years, 2 months ago by clydesanchez32.
    • This topic was modified 9 years, 2 months ago by clydesanchez32.
    • This topic was modified 9 years, 2 months ago by clydesanchez32.
    • This topic was modified 9 years, 2 months ago by clydesanchez32.
    • This topic was modified 9 years, 2 months ago by Ally. Reason: Removed API key
    Attachments:
    You must be logged in to view attached files.
    #13797
    clydesanchez32
    Participant

    Hi, I haven’t heard back about my issue and just wanted to check in.

    Thanks!

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

    #21412
    clearscope
    Participant

    Hello,

    With our Mailchimp integrated Quform form, we are receiving this popup error when a submission is made and when that email address is already subscribed to the mailing list:

    “An error occurred submitting the form”

    When you do the same from the default Mailchimp hosted signup form, it displays the message: “email@domain.com is already subscribed to list…”

    Is there a way that we can have the Quform error message state the same as the Quform error message, to tell the user that the email address is already subscribed?

    The problem is that in such instances, with the current unspecific error message, it does not tell the user that the email address is already subscribed, so they end up contacting the company to report a problem or to ask why they can’t subscribe, when if fact it’s simply because they are already subscribed.

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

    #21428
    clearscope
    Participant

    Hi – thank you

    We do need to be able to display a message to the user that the address is already subscribed.

    Is it possible to provide the example referenced but modified for the v2 API?

    Or would it be better to change the version of the API that we are using to match the example?

    I’m just not sure how to do either. Here is the current code that we are using:

    function my_save_to_mailchimp($form)
    {
        if (!class_exists('Mailchimp')) {
            require_once dirname(__FILE__) . '/Mailchimp.php';
        }
    
        $mailchimp = new Mailchimp('mailchimpid');
        $listId = 'listid';
        $email = $form->getValue('iphorm_23_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_23_1'),
            'MERGE2' => $form->getValue('iphorm_23_2'),
            'MERGE3' => $form->getValue('iphorm_23_4'),
            'MERGE4' => $form->getValue('iphorm_23_5'),
            'MERGE6' => $form->getValue('iphorm_23_6'),
            'MERGE17' => $form->getValue('iphorm_23_7')
        );
    
        // Other settings
        $emailType = 'html';
        $doubleOptin = false;
        $updateExisting = false;
        $replaceInterests = false;
        $sendWelcome = false;
    
        $mailchimp->lists->subscribe($listId, array('email' => $email), $mergeVars, $emailType, $doubleOptin, $updateExisting, $replaceInterests, $sendWelcome);
    }
    add_action('iphorm_post_process_23', 'my_save_to_mailchimp', 10, 1);
    #21434
    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.

    #21435
    clearscope
    Participant

    Thank you!

    That is absolutely perfect and much appreciated.

    Thank you for all of the top notch support!!!

Viewing 8 posts - 1 through 8 (of 8 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