Hi,

I've been trying to solve this for a couple of days now, but I'm still nowhere on this.

What I want to do: I have around 200 members and 7 types of roles (Board, Eduction Committee, ...).
Al these 200 members have one or more roles assigned.

I have installed Mailchimp and configured everything correctly I think.
Lists are being imported, signups forms works, etc.

Now I want to assign all existing users with a certain role to a certain Mailchimp list. I know this has to be done with Rules.
Can someone help me with this?

I've got so far that a users gets assigned when the user account is saved, but then I would have to open all the 200 members and save them again first. Also, I think Rules is reading MY role, and not the role of the users. This is what I've got:

Event: Before saving a user account
Condition: User has role(s), Parameter: User: [site:current-user], Roles: Board Member
Action:  Subscribe or unsubscribe entity from a mailchimp list, Parameter: Entity: [account], Mailchimp List Subscription Field: [account:field-board-members], Subscribe: true

But I want Rules to read the roles of all the existing users, and when running cron, subscribe them to the right lists...

Thank you for your help!

Comments

MegaChriz’s picture

Status: Active » Fixed

You can follow these steps:

  1. Create a Rules component of type "Rule" that performs the subscribe action (see below for an example).
  2. Install the Views Bulk Operations module.
  3. Create an user based View (optionally with a page display).
  4. Add a bulk operation field to the View. In the settings of this field, select the created Rules component.
  5. Save the View.
  6. Go to the page where the View is displayed.
  7. Select all users in the View.
  8. Execute the action that represents the Rules component.

Done.

Rules component example for subscribing an user with a certain role:

{ "rules_mailchimp_subscribe_roles_board" : {
    "LABEL" : "Subscribe board members",
    "PLUGIN" : "rule",
    "OWNER" : "rules",
    "TAGS" : [ "Mailchimp" ],
    "REQUIRES" : [ "rules", "mailchimp_lists" ],
    "USES VARIABLES" : { "account" : { "label" : "Account", "type" : "user" } },
    "IF" : [
      { "user_has_role" : { "account" : [ "account" ], "roles" : { "value" : { "5" : "5" } } } }
    ],
    "DO" : [
      { "mailchimp_lists_user_subscribe" : {
          "entity" : [ "account" ],
          "field" : [ "account:field-board-members" ],
          "subscribe" : "1"
        }
      }
    ]
  }
}

Status: Fixed » Closed (fixed)

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

capysara’s picture

This worked great for me! Thanks!

Now that my large list of users is correct, I want to keep my list updated as I add new users. I could run the Views Bulk Operation periodically or I could possibly set up a rule that runs when user accounts are updated. I've heard that MailChimp can be very particular about things and I would not want to get flagged for repeatedly subscribing users. Is there any harm in performing the Subscribe action more than once on a user?