Signup/signout & 'check if signed' up are available as Rule actions/condition #1593224: provide rules integration for 7.x-2.x
But we can't move users to a certain MailChimp group yet based on a Rule Action.

This would enable us to put users in MailChimp groups based on everything that we can reach with Rules like product purchases, Role, Profile, Userpoints, Link clicked, page visited, age, site activity, etc.

This piece of code seems to contain code on how to move a member to a different MailChimp group through the Mailchimp Module (API):
and may be partly reusable

Information about what MailChimp groups are, and how they can be valuable in email marketing:

#11 mailchimp73-group-1808704-11.patch8.98 KBMegaChriz
PASSED: [[SimpleTest]]: [MySQL] 64 pass(es).
[ View ]
#6 mailchimp-group-1808704-6.patch3.99 KBklausi
Test request sent.
[ View ]
#1 mc_subscribe_group_rules.patch3.26 KBhibersh


hibersh’s picture

Status:Active» Needs review
new3.26 KB

Rule action "Subscribe user to a mailchimp group" added

It will be great that have groups property for list entity

silkogelman’s picture

Title:Ability to put a Member into a Group with a Rule Action» Ability to put a Member into a MailChimp Group with a Rule Action

clarifying title to make sure people don't think it's about Organic Groups

silkogelman’s picture

Issue summary:View changes

updated with link to code that contains clues on how to do this

jsibley’s picture

Issue summary:View changes

It has been more than a year since this patch was offered.

Could it please be committed if it works?

This would make mailchimp significantly more useful within Drupal, since mailchimp autres in favor of having one one list and using groups for segmentation.

jsibley’s picture

It looks like the patch needs to be redone to work with the current dev or recommended versions, as it was never committed and development continued.

Since it looks like the current dev is not recommended for production, if I produce a working patch for the current recommended version, would it be committed? This would be my first patch, but I'm willing to try. It looks like just the line numbers need to be adjusted.

rvb’s picture

Thanks jsibley for doing this. This would be a great feature to have!

klausi’s picture

new3.99 KB
Test request sent.
[ View ]

Updated the patch a bit: use an email address instead of a user object, so that you also can subscribe raw emails without users. Changed the option list to use the machine name instead of the numeric list ID.

Currently the action replaces whatever groupings are specified, the Mailchimp API leaves other groupings that are not mentioned in the request as is anyway.’s picture

ok, I'm trying to get this working (D7, 7.x-3.1).
What should I select as "actions"?
I tried:
entity data selector: account
Mailchimp List Subscription Field entity selector: ??
Add subscription: yes

adam_b’s picture

Has anyone got farther with this? I'd love to be able to specify groups - but so far I can't even get the patch to apply successfully.

adam_b’s picture

Got klausi's patch applied to v2.12, thanks to a friend.

But although I can see the new action "Subscribe email to a mailchimp group", when I select and try to save it I get an error:
Unknown action mailchimp_lists_user_subscribe_intgroup.

MrPeanut’s picture

new3.26 KB

I have applied @klausi's patch from #6. I do see the Group in the Group ID fieldset. However, I'm not really sure what the Groups fieldset is for. It says "The group values separated by commas."


I've entered the group's numerical ID and also the sub-group's numerical ID. Neither one seems to work. I've tried users who are already subscribed and users who are not yet subscribed.

In any case, I'd like to be able to subscribe a user into one of that group's groups. (For example, my "Main Group" has Washington St Location, Riverview Ave Location, etc.)

Lastly, it might be worth moving this development to the 3.x branch.

MegaChriz’s picture

Version:7.x-2.x-dev» 7.x-3.x-dev
new8.98 KB
PASSED: [[SimpleTest]]: [MySQL] 64 pass(es).
[ View ]

Here is a patch for the 7.x-3.x version. The implementation is a bit different from the patch from #6, which was for the 7.x-2.x version. This patch provides two Rules actions:

  • Subscribe email to a mailchimp group
    This action subscribes a mail address to one or more (sub)groups from a single interest group. It doesn't unsubscribe the mail address from other (sub)groups from the same interest group.
    If the mail address is not yet subscribed or unsubscribed it will be (re)subscribed with a single opt-in (no confirmation mail).
  • Unsubscribe email from a mailchimp group
    This action unsubscribes a mail address from one or more (sub)groups from a single interest group. In case the mail address is currently not subscribed, the action will do nothing.

About configuring the actions

Both actions will ask you first for the mail address and the interest group ID. After that a list of available groups within that interest group is loaded (eventually via AJAX).
The code for this is taken from rules_action_type_form_alter() in rules/modules/

Tested with checkboxes only

In only tested this with interest groups where multiple options are allowed (thus with interest groups that are set in MailChimp as checkboxes), not with single option interest groups (radio buttons).

MrPeanut’s picture

Patch from #11 is working great!! Thank you so much, MegaChriz. That works terrific.

[edit] What would it take to send additional merge fields (e.g. address, city, state, particularly from a Commerce order)?

CountPacMan’s picture

It's a beautiful patch, but I'm getting an error when adding a rule:

Undefined index: intgroups in mailchimp_lists_groups_options_list() line 103 in .../../mailchimp_lists/

This is the option list callback for the group subscribe action that you added. Do you have any ideas about what may be causing this? I have created a group on a list in MailChimp, added subscribers to it, and can add it in rules with your patch, but I still get this error.

silkogelman’s picture

Issue summary:View changes
silkogelman’s picture

Issue summary:View changes
MrPeanut’s picture

I am having issues with my user getting updated and losing their groups.

Upon checkout, a user's billing address is copied to an address field on their user profile. I have a Boolean field on my order checkout. If checked, they are subscribed to a list and a group within that list.

The address gets copied to Mailchimp via a Mailchimp field on the user profile (which uses tokens to map the address data).

On checkout, the rule fires to subscribe them to the list. However, there's a second event in my log at the exact same time that says that user was updated. I'm assuming this is when they lose their interest groups.

Would anyone happen to have any idea why they're losing the groups or anything I could do to further test?

Greg Boggs’s picture

Status:Needs review» Needs work
MrPeanut’s picture

Regarding #16, I found that the event Completing the checkout process was causing the issue. Apparently something else was causing the account to be updated during that same event. I changed it to schedule a component evaluation and it seems to be working.

Now I am having trouble getting their address sent via a Mailchimp subscription field (it works if I change a value and save, but doesn't work on the initial subscription), but that is probably a separate issue than this.

MrPeanut’s picture

Sorry to be taking over this issue, but #18 does not completely fix the issue. If I edit a user, they still lose their groups. I do have a Mailchimp subscription field on the account (as that is how I was able to link the Drupal user account address field to the Mailchimp address merge field). Could the Mailchimp subscription field be "erasing" the group info when a user is updated?