I installed mailchimp succesfully and everything seems to be working fine. But when a new account is created the user is always added to the mailchimp list even thought they turn the checkbox off during registration.
When the new user goes to his profile and unchecks the newsletter box again then he is succesfully unregistered.

I am using an optional list and these are the options that I have enabled:
Show subscription options on the user registration form.
Default to opt-in on registration form. (turning this off doesn't help the problem)
Show Subscription Options on User Edit Screen

Am I doing something wrong?

Comments

redsd’s picture

StatusFileSize
new1.52 KB

There seems to be a bug in the mailchimp_list module.

When a user is created, it will always call mailchimp_lists_user_sync.
It sends the account object aswell, so the funtion will add the account that is send to the subscibe list.

I changed the placement of the function only to be called when a user subscribes, this way people who want to subscribed still get added to the list, and people who don't subscribe won't be added.

redsd’s picture

Status: Active » Needs review

Can someone confirm this patch is correct btw? :)

ttiurani’s picture

I'm having this problem too. The above patch doesn't solve the problem for me unfortunately: when registering with the newsletter unchecked, I still get three watchdog notifications "[user] was subscribed to list [list]" and the user is subscribed on the account page.

Any ideas?

ttiurani’s picture

I got things to work by changing one line back to a previous version with this change:

index bd63e20..8d27bb3 100644
--- a/sites/all/modules/mailchimp/modules/mailchimp_lists/mailchimp_lists.module
+++ b/sites/all/modules/mailchimp/modules/mailchimp_lists/mailchimp_lists.module
@@ -356,7 +356,7 @@ function mailchimp_lists_user_sync($account, $old_email = '', $new_email = '', $
   }
 
   // Add subscriptions if necessary
-  $lists = mailchimp_lists_get_available_lists($account, array(MAILCHIMP_LISTTYPE_REQUIRED, MAILCHIMP_LISTTYPE_OPTIONAL));
+  $lists = mailchimp_lists_get_available_lists($account, array(MAILCHIMP_LISTTYPE_REQUIRED));
   if (!empty($lists)) {
     $mcapi = mailchimp_get_api_object();
     foreach ($lists as $list) {
redsd’s picture

Strange, because the fix I made would only be called if the checkbox was actually checked.

Maybe upload the patch here :)

gcb’s picture

Version: 7.x-2.10 » 7.x-2.x-dev
Assigned: Unassigned » gcb
Status: Needs review » Needs work

Thanks for spotting this Kiampp. I'm looking into it and finding various subtle issues in the subscription patterns: this patch doesn't quite cover the whole issue, and it may require a minor re-factoring. I'll post again when I get a fix into the Dev tree.

c.breschkow’s picture

#1 worked for me

gcb’s picture

Status: Needs work » Closed (fixed)

Thanks for your patience everyone. This is fixed in the latest dev release (should roll tonight), and will be rolled into 7.x-2.11 before long. We have built in tests to avoid issues like this recurring in the future.