Hi there,

I have the following use-case:

  1. people create a user account and should be subscribed automatically to a Mailchimp newsletter as soon as they are validated (role: authenticated user)
  2. not only should they be auto-subscribed to the general list, but to a certain interest group in this list, based on a profile2 field information
  3. however, they should be able to manage their subscription through the user edit page, which is only possible for optional lists

From what I gather from the mail chimp module settings, auto-syncing users is only possible with required lists, as are Interest Groups and user manipulation for active subscriptions. Does anyone with a similar use case have some best practices on how to achieve this?

Comments

a.ross’s picture

Title: [best practice] Auto-subscribe to optional list when user is created » Auto-subscribe to optional list when user is created
Category: support » bug

This should be pretty straightforward to achieve using Rules, although that feels like a bit of a workaround. You can create a rule like this:

  • Event: After updating an existing user account
  • Condition: User is blocked (account-unchanged)
  • Condition: NOT User is blocked (account)
  • Action: Subscribe user to a mailchimp list (account) ("List")

In case you don't use admin approval of an account, the rule will be simpler:

  • Event: After saving a new user account
  • Action: Subscribe user to a mailchimp list (account) ("List")

Only I can't seem to get the actual action working. What exactly are we supposed to fill in for "list"? I tried the name of the list and the ID, both aren't working. What am I missing? Additionally, the module doesn't provide any integration with Rules to change interest groups for a user.

a.ross’s picture

Could it be due to this issue (#1593224: provide rules integration for 7.x-2.x) not being resolved yet?

a.ross’s picture

Ah, I've been able to resolve the first issue, which is what to fill in for the "List" the user will be added to. You should use the machine name of the list, as displayed in admin/config/services/mailchimp/lists/<ID>/edit right next to the Label field. It's confusing though, and it still qualifies as a bug IMO.

antipex’s picture

Status: Active » Closed (works as designed)

This seems to work fine with Rules.

a.ross’s picture

Status: Closed (works as designed) » Active

Uh, why are you closing this issue? No, it does not work as expected. In fact, this issue covers not 1, but 2 bugs.

levelos’s picture

Status: Active » Closed (works as designed)

@a.ross, the module is not designed to automatically subscribe users to optional lists, hence the name, and we will not make that change at this time. You can accomplish something similar on your own using Rules or custom code. If this issue does cover 2 bugs, as you put it, then post a focused issue for each issue. But something not working like you want is not a bug.

a.ross’s picture

Status: Closed (works as designed) » Active

The OP was addressing 2 issues. The first was subscribing someone to a list upon registration. I wanted something similar so I ran into this thread. Personally, I notably do not want to auto-subscribe new users to an optional list, I just want the checkbox to be checked by default, as opposed to unchecked, as it is now. However I can live with using Rules as a workaround.
Even though this isn't possible, I haven't been arguing to "fix" this at all, as you can read. The only thing I argued needs fixing is the Rules integration. It does work, but there is no documentation how it works in the absence of a proper form component (like a dropdown with all mail lists). I didn't even go as far as saying that the absence of said form component was a bug, merely that it needs to be documented how the direct input works. Not everybody will figure it out on their own that one needs to use the machine name of the list, and not the label or the ID.

The second issue was automatically adding someone to an interest group. It would be enough if this could be achieved with Rules, however that feature currently doesn't exist. I'm ok with branching that off to another thread, but this issue still shouldn't be closed.

levelos’s picture

Status: Active » Fixed

The title of this issue is

Auto-subscribe to optional list when user is created

That is a feature request. As discussed here, it can be accomplished using Rules and will not be done in another way. If you feel it should be documented better, than add a feature request under a documentation component. Or better, add some documentation in the form a patch.

The fact that Rules integration doesn't support interest groups is also a feature request, or arguably a bug. Either way, it doesn't belong in this thread.

a.ross’s picture

No, I'm done on this issue queue...

tobias.grasse’s picture

Thanks to a.ross for pointing me to Rules, and to levelos for reminding everyone that "optional list" is named adequately :) I do not want to reopen this issue, but to leave some hints for people with the same problem:

My original problem was that the list should be optional in order that users can unsubscribe in their account settings (after they've registered), but that the initial subscription is somewhat "mandatory" and you should only have to choose one or more interest groups. If I set the list to "required", users can neither unsubscribe through their account settings page nor can they choose interest groups while signing up, as IG only work with optional lists.

So Rules does not cover the IG part here, but I finally achieved it with a form_alter, setting the default for "subscribe to list" checkbox to TRUE. If you want the signup to be really "required", you could set the default to true and unset the form element afterwards. I strongly recommend taking a look at Form API for setting default values.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.