For our installation, the signup form will be used by anonymous users, some of whom may already be subscribed to some of our other newsletters. Our MailChimp account is set up with all users in a single list, and with 9 groups within the list.

We're finding that if an anonymous (Drupal), existing (in our MC list) user signs up through this form, their existing group subscriptions are overwritten. This is a non-starter for us, as it would essentially unsubscribe these users from some of our mailings. People do not generally remember what they are subscribed to.

Ideally, we'd like the form to be "smart" enough to pull an existing subscriber's data from MC and display them for the user.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

levelos’s picture

Status: Active » Closed (works as designed)

This is not possible for an anonymous user, and you probably shouldn't mix existing segmented lists with a generic sign up form available to anonymous users on the site. Regardless, it's not a problem the module can solve.

smoothify’s picture

Version: 6.x-2.3 » 6.x-2.x-dev
Component: Code » General
Status: Closed (works as designed) » Active

Sorry to open such an old issue, but i also have the same situation, which I currently get by with a modified version of the module which i'd prefer not to do. I'm using 6.x-2.x but i see the issue is still present in 7.x-2.x.

Keeping email addresses in a single list and separating subscriptions using groups is something that mailchimp recommend and also makes financial sense as you don't pay multiple times for people that have multiple subscriptions.

There is a relatively simple way to give an option, either through the ui or through some kind of hook.

The api function listUpdateMember has a parameter - $replace_interests, which by default is true. If its set to false, it means that any ticked interests groups would be *added* to any users existing interest groups.

 function listUpdateMember($id, $email_address, $merge_vars, $email_type='', $replace_interests=true) {
...
} 

Obviously not suitable for authenticated users, but perfect for anonymous users where we don't have their default groups.

My suggestion would be to add a new optional parameter to _mailchimp_subscribe_user (in 6.x-2.x) and mailchimp_update_user in (7.x-2.x)

Then in mailchimp_subscribe_anon_form_submit (or the 7.x-2.x) alternative, the replace_groups parameter could be passed in, perhaps based on a variable for the current list.

smoothify’s picture

Status: Active » Needs review
FileSize
4.07 KB

Here is a patch for 6.x-2.x for your consideration.

I added an option for preserving the interest groups to the user settings fieldset, when this is checked any interest groups selected will be added to those already set for the subscriber.

I set the option to default to false as i didn't want to change the behaviour, but I personally I would think it would be more common to want to preserve the groups than replace them.

pmchristensen’s picture

Issue summary: View changes
FileSize
1.43 KB

Had same problem for 7.x-3.x. I think it is incorrect that this shouldn't be supported - when is it the case that you what a subscription form to also "unsubscribe" you to something? I have solved it with the following patch which I think should be adapted - didn't thought it should be an option as the form is a subscription form and therefore shouldn't do unsubscribing stuff.

Status: Needs review » Needs work

The last submitted patch, 4: existing_subscriber-1035906-4.patch, failed testing.

pmchristensen’s picture

Version: 6.x-2.x-dev » 7.x-3.x-dev
Status: Needs work » Needs review
FileSize
4.67 KB

Corrected the patch made in comment #4, so it's now an option on the creation if it's preferred to preserve interest groups or not - defaults to true. Also added a setting for an update message when an email is submitted but already is subscribing.

jphelan’s picture

Same issue, patch #6 seems to have fixed it for me.

pmchristensen’s picture

Status: Needs review » Reviewed & tested by the community

The last submitted patch, 3: 1035906-existing-subscriber-groups-overwritten-patch.diff, failed testing.

pmchristensen’s picture

Status: Reviewed & tested by the community » Patch (to be ported)
FileSize
4.65 KB

Made the patch for the newest develop, please adopt this patch!

nedjo’s picture

Status: Patch (to be ported) » Needs work

@levelos: can you review and explain in more detail why this shouldn't be done?

Quick code review.

  1. +++ b/modules/mailchimp_signup/includes/mailchimp_signup.admin.inc
    @@ -97,6 +97,13 @@ function mailchimp_signup_form($form, &$form_state, MailchimpSignup $signup) {
    +    '#title' => 'Update Message',
    

    This and several other strings should be localized.

  2. +++ b/modules/mailchimp_signup/mailchimp_signup.module
    @@ -365,11 +365,13 @@ function mailchimp_signup_subscribe_form_submit($form, &$form_state) {
    +    $result = mailchimp_subscribe($list_id, $email, $mergevars, $signup->settings['doublein'], $signup->settings['send_welcome'], 'html', TRUE, !$signup->settings['preserve_interest_groups']);
    

    The last argument added here could use an explanatory comment. Why does it use the ! operator?

  3. +++ b/modules/mailchimp_signup/mailchimp_signup.module
    @@ -381,9 +383,12 @@ function mailchimp_signup_subscribe_form_submit($form, &$form_state) {
    +  if (count($successes) && isset($signup->settings['confirmation_message']) && strlen($signup->settings['confirmation_message']) && empty($member)) {
    

    Could use a code comment. What's going on here?

  4. +++ b/modules/mailchimp_signup/mailchimp_signup.module
    @@ -381,9 +383,12 @@ function mailchimp_signup_subscribe_form_submit($form, &$form_state) {
    +    drupal_set_message($signup->settings['update_message'], 'status');
    

    Does this need check_plain()?

levelos’s picture

Assigned: Unassigned » jami

@nedjo, not sure I can clarify the comment I made 4 years ago, but we're happy to revisit this and see if it still makes sense and can be cleanly applied. Thanks, as always, for your community stewardship.

@pmchristensen, do you want to revisit your patch per @nedjo's comments? The patch is also mixing issues as the matter of overwritten interest groups is not ties to the addition of an update message.

MegaChriz’s picture

Title: Existing subscriber data overwritten » Existing subscriber data overwritten when using a signup form
CountPacMan’s picture

Status: Needs work » Reviewed & tested by the community

The latest patch here https://www.drupal.org/node/2510640 seems to fix the bulk of this issue. (https://www.drupal.org/files/issues/mailchimp-prevent-overwrite-on-entit...)

Anything beyond this seems like it would be a feature request.

Greg Boggs’s picture

Assigned: jami » Unassigned
Status: Reviewed & tested by the community » Needs work

In light of the progress made on the related issue above and the fact that the patch in #10 needs at least a reroll, I cannot commit this patch as is. If this feature is important for you, please consider posting a reroll and testing it.

The last submitted patch, 10: existing_subscriber-1035906-9.patch, failed testing.

ruscoe’s picture

Status: Needs work » Closed (won't fix)

We're going to be ending support for the 7.x-3.x branch due to the upcoming deprecation of the v2.0 MailChimp API. If you're still seeing this issue with the most recent release, please feel free to reopen.