Summary:

If "Interest Groups" is enabled in the field setting with a non-empty interest group, one cannot unsubscribe from the list. The entity form is submitted successfully but the email address is still in the MailChimp list.

Steps to reproduce:

  1. Install the module: mailchimp 7.x-5.2.
  2. Download the MailChimp library with version 1.0.10.
  3. Enable mailchimp_lists.
  4. Set a MailChimp API key.
  5. Create a field with "Enable Interest Groups" checked (the target list should have at least one interest group):
  6. Save an entity with "Subscribe" checked then re-save with "Subscribe" unchecked.
  7. You can see unsubscription doesn' work.

I guess this is introduced in #2962167: Removing a single Interest Group is causing an Unsubscribe from the list .

Comments

hgoto created an issue.

jdhildeb’s picture

I tried upgrading to 7.x-5.2 and can confirm that I experienced the same issue as described in this ticket.

jim22’s picture

I am seeing this same issue with Mailchimp 7.x-5.4.

tomarnold2’s picture

Hi, all. Happened across the fix for this one today. I'm using 7.x-5.6.

On line 269 in mailchimp_lists.module it currently reads:
if (count($interests) > 0 && $function == $field['settings']['unsubscribe_action']) {

The issue is that count($interests) is always > 0 for me even when they're all unchecked (because it is an array of items showing whether they are checked or not). Further up in the code it was checked to see if the user had unsubscribed or not and, if so, $function was set to 'remove' but line 269 undoes that status and sets it to 'update'. In this situation, where you have interest groups, the user can never unsubscribe.

Here's the change I made to address this:
if (count($interests) > 0 && $function == $field['settings']['unsubscribe_action'] && $function != 'remove') {

I make sure the 'remove' status remains so that the switch() statement below properly calls mailchimp_unsubscribe_member().

Hope this helps. I'll come back and submit a patch when I have a little more time but thought this would at least help some folks in the meantime. (Or someone else can submit the patch if you have time.)

Tom