PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

MailChimp and Checkboxes

  1. Anonymous
    Unregistered

    I had two groups in MailChimp that were hidden in their form for segmenting. They don't show up as options to map a gravity form input (checkboxes). I set the group to not be hidden in MailChimp. They still don't show up as options to map a gravity form.

    In a perfect world, I make a single hidden field in gravity forms for a particular option on the group, and pass that to MailChimp for the Type field to a specific option.

    Ie, I have a group - Fruit. Options are apple, banana, grape. If visitor fills out form 4, I pass a hidden field to MailChimp for the Fruit group as apple.

    Any insight into why Gravity Forms isn't seeing these checkbox options?

    Posted 13 years ago on Tuesday January 18, 2011 | Permalink
  2. Anonymous
    Unregistered

    OK, I just checked again, and it seems that even though MailChimp treats groups as part of the form, they aren't included in the List fields.

    I will follow up with them and report back anything I discover in case anyone else tries to bend these two tools in a manner they might not have originally been intended…

    Posted 13 years ago on Tuesday January 18, 2011 | Permalink
  3. Anonymous
    Unregistered

    Hmm, reading through this specific forum, though the topics didn't turn up in a search, it seems that this is an oft requested feature, and the response going back at least 10 months is that it's something planned. Any time line?

    I'm assuming then their API supports it, it's just not built into the add-on?

    Posted 13 years ago on Tuesday January 18, 2011 | Permalink
  4. We do intend to add this functionality, but we don't have a time line yet. Their new API does support that feature, but it expects batches of emails to be added at once to a segment, so that might pose some problems with the integration since Gravity Forms adds one email at the time. I am pretty sure we will be able to figure something out, but to be honest, it will probably take a little while before we can get to this feature.

    Posted 13 years ago on Tuesday January 18, 2011 | Permalink
  5. Anonymous
    Unregistered

    Fair enough. Thanks for taking time to reply.

    Posted 13 years ago on Tuesday January 18, 2011 | Permalink
  6. dndco
    Member

    Hello, I could not wait for these enhancements to be made so I updated (hacked) the MailChimp 1.3.2 Add-on code myself to add this functionality.

    1) Hidden Gravity Form Text Field Maps to Mailchimp Groups. (The hidden field name and group name must match exactly or user doesn’t get inserted or updated.)

    2) If user already exists in the MailChimp list, update the user information in instead of doing nothing.

    3) If any type of insert/update error occurs when calling MailChimp API send email with error code, error description and the submitters information to admin of website.

    I'd be happy to share my code updates if this functionality is still desired by anyone.

    Posted 13 years ago on Wednesday April 13, 2011 | Permalink
  7. dndco,
    This is exactly what I am trying to accomplish. Would you mind sharing your code with me?

    Thank you for your time

    Posted 13 years ago on Friday April 29, 2011 | Permalink
  8. dndco,
    I could use the same functionality. Can you please share the update with me as well.

    Posted 13 years ago on Friday April 29, 2011 | Permalink
  9. dndco
    Member

    Hi @mgyura and @motherny,

    These updates aren’t completely seamless so you will have to update some code hard coding a few values but on the front end it is working perfect for us.

    Browse to your gravityformsmailchimp folder -> open mailchimp.php
    Scroll to line 592 OR search for “$merge_vars = $api->listMergeVars($config["meta"]["contact_list_id"]);” in the “private static function edit_page()” function.

    Paste this line of code right below the line of code above.
    //Added by dndco to allow for the G-Form mapping of Hidden text group names. array_push($merge_vars, Array("name"=>'INTERESTS', "req"=>"", "field_type"=>"text", "public"=>"1", "show"=>"1", "order"=>"7", "default"=>"", "helptext"=>"", "size"=>"25", "tag"=>"INTERESTS"));

    This forces an element into the merge_vars array called INTERESTS which you will map to your hidden field on your G-form through your Admin.

    You will most likely have to update the value assigned to “order” shown above. Order is where your interest group’s form element exists in your Mailchimp form.

    So if your Mailchimp form has these elements … FName, LName, Email, Group Checkboxes … order would be set at 4 for this example as your Group Checkboxes are in the 4th spot/location on the Mailchimp Form.

    Scroll to line 698 or search for “$merge_vars = $api->listMergeVars($list_id);”
    Paste this line of code again below the above line and make sure to update your order value to match the order of your Mailchimp list.

    //Added by dndco to allow for the G-Form mapping of Hidden text group names. array_push($merge_vars, Array("name"=>'INTERESTS', "req"=>"", "field_type"=>"text", "public"=>"1", "show"=>"1", "order"=>"7", "default"=>"", "helptext"=>"", "size"=>"25", "tag"=>"INTERESTS"));

    Those two pieces of code will allow you to map your hidden G-Form element to a MailChimp form element called “INTERESTS” and will insert the group name into Mailchimp.

    *** YOU HAVE TO MAKE SURE YOUR G-FORM HIDDEN ELEMENT NAME/VALUE MATCHES YOUR MAILCHIMP GROUP NAME VALUE EXACTLY. ***

    ex. If your interest group for this form is “Fine Dining” then your hidden G-form element has to be “Fine Dining” spelled exactly the same.

    Now we will update a user’s info if they already exist in the list.

    Scroll to line 1059 or search for “$retval = $api->listSubscribe($feed["meta"]["contact_list_id"], $email, $merge_vars, "html", $double_optin, false, true, $send_welcome );”

    Paste this code below the line of code above.

    //Start of dndco’s code
    if (!$retval) {
    switch($api->errorCode) {
    case '214' :
    $retval = $api->listUpdateMember($feed["meta"]["contact_list_id"], $email, $merge_vars, "html", false);
    break;
    default:
    $errormsg = $api->errorCode.":".$api->errorMessage;
    // send e-mail to admin with MailChimp Error
    $emailAdmin = get_option('admin_email');
    // Your subject
    $subject = "Gravity Form to MailChimp Error";
    // Your message
    $message = "An error occurred during MailChimp insert for user " . $email . " Error information: ";
    $message.= $errormsg;
    // send email
    $sentmail = wp_mail($emailAdmin, $subject, $message);
    break;
    }

    }
    //End of dndco’s code

    Code description: If $retval throws any type of error capture it and evaluate. Error code 214 means user already in list so we want to update info if error == 214. If error != 214 send an email to the admin of the WordPress site with the MailChimp error code, description and email address of user submitting the form.

    Again it’s not elegant but it works for our situation and allows us to have one MailChimp list with multiple interest groups.

    Hope this helps.

    Posted 13 years ago on Tuesday May 10, 2011 | Permalink
  10. Thanks dndco,
    I'll give it a try now and report back.

    Posted 13 years ago on Tuesday May 10, 2011 | Permalink