The section of code in constant_contact_user() will unsubscribe users if user_save() is called as an api function (in our case, via the migrate module)
if(isset($edit['cc_newsletter']) && $edit['cc_newsletter']):
$status = $cc->update_contact($contact['id'], $edit['mail'], array_keys($lists), $fields);
elseif (isset($edit['cc_newsletter'])) :
$status = $cc->update_contact($contact['id'], $edit['mail'], array(), $fields);
endif;
furthermore, even without that little gotcha, it slows the import process down by several orders of magnitude by unnecessarily contacting constant contact. The attached patch does 2 things. First, it aborts the function if $edit['cc_newsletter'] is not set (which is an indication that user_save() was called from a source other than the user edit or user registration form, and secondly, it updates the code above to explicitly only act if the cc_newsletter variable is present. I'm not familiar enough with the code here:
else:
if(isset($account->cc_newsletter) && $account->cc_newsletter):
$status = $cc->update_contact($contact['id'], $account->mail, array_keys($lists), $fields);
else:
$status = $cc->update_contact($contact['id'], $account->mail, array(), $fields);
endif;
endif;
to know if and how it is called. It may need a similar elseif (isset($account->cc_newsletter)) to avoid inadvertent unsubscribe requests being sent to constant contact.
| Comment | File | Size | Author |
|---|---|---|---|
| constant_contact.user_save.patch | 1.07 KB | jhedstrom |
Comments
Comment #1
jhedstromCorrection, the code posted above includes the patch...so the original code is this:
Comment #2
justphp commentedOk, thanks for taking the time to report this problem, I'll be releasing an update with some new features next week so will get this fixed at the same time.
Comment #3
justphp commentedComment #5
Anonymous (not verified) commentedSorry to open this again, but this patch breaks the module when the selected method is checkbox and not list. This code fixes it:
Sincerely,
Leighton Whiting
Comment #6
locomo commentedi can confirm the fix in #5 works for me
Comment #7
justphp commentedI'll add it to the next release. Thanks.
Comment #8
justphp commentedFixed in git, will be deployed with the next release,