offshot from #1307222: provide rules integration to care for d7 specifically

* condition: User is subscribed to a list
* action: Subscribe user to a list
* action: Unsubscribe user from a list

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

fago’s picture

Status: Active » Needs review
FileSize
3.4 KB

and the patch..

levelos’s picture

Status: Needs review » Fixed

Thanks @fago. Also added the new rules file to .info.

klausi’s picture

@levelos: No need to add the file to the info file, this is only needed for files containing classes/interfaces. See http://drupal.org/node/542202

This is also detected by drupalcs, see http://ventral.org/pareview/httpgitdrupalorgprojectmailchimpgit

chris23’s picture

What about subscribing a user to a particular group within a list?

levelos’s picture

Thanks @klausi, got it.

mh86’s picture

Status: Fixed » Needs review
FileSize
1.77 KB

The current action for subscribing an email takes the user as argument. In some certain cases you might have an email address, but the user is anonymous (e.g. you add a user to a mailchimp list when he starts with an order checkout as anonymous user).
So I thought about adding another action that simply takes the mail address as input. Compared to the existing subscription action, no merge fields are supported. I hope the approach of having 2 actions is not too confusing to people, but both have their use cases. What do you think about it?

Lloyd’s picture

What value needs to be entered as the Mailchimp list identifier? I tried using the number of the list in Drupal (e.g. 1, 2, 3), as well as the name (e.g. general_mailing_list). Neither seem to work.

Lloyd’s picture

Okay, question answered but it brought up a potential issue.

The answer to my above question is that "general_mailing_list" (whatever the machine readable list is called in Drupal) is correct.

It didn't work for me because to test it I went in to Mailchimp (directly, not through Drupal) and unsubscribed. Because the Mailchimp module in Drupal thought I was subscribed it did not send the subscription request to Mailchimp.

jt55401’s picture

Version: 7.x-2.x-dev » 7.x-2.5

I am able to successfully get the rules working to SUBSCRIBE a user, but unsubscribe does not work for me.

For reference, here is my SUBSCRIBE rule, it works fine:

{ "rules_trading_plan_alerts_on" : {
    "LABEL" : "Trading Plan Alerts: On",
    "PLUGIN" : "reaction rule",
    "TAGS" : [ "email" ],
    "REQUIRES" : [ "rules", "mailchimp_lists" ],
    "ON" : [ "user_insert", "user_update" ],
    "IF" : [
      { "NOT data_is_empty" : { "data" : [ "account:field-newsletter" ] } },
      { "AND" : [] },
      { "data_is" : { "data" : [ "account:field-newsletter" ], "value" : 1 } }
    ],
    "DO" : [
      { "mailchimp_lists_user_subscribe_list" : { "account" : [ "account" ], "list" : "newsletter" } }
    ]
  }
}

Here is my UNSUBSCRIBE rule, it does NOT work:

{ "rules_trading_plan_alerts_off" : {
    "LABEL" : "Trading Plan Alerts: Off",
    "PLUGIN" : "reaction rule",
    "TAGS" : [ "email" ],
    "REQUIRES" : [ "rules", "mailchimp_lists" ],
    "ON" : [ "user_insert", "user_update" ],
    "IF" : [
      { "data_is_empty" : { "data" : [ "account:field-newsletter" ] } },
      { "OR" : [] },
      { "data_is" : { "data" : [ "account:field-newsletter" ], "value" : 0 } }
    ],
    "DO" : [
      { "mailchimp_lists_unsubscribe_list" : { "mail" : [ "account:mail" ], "list" : "newsletter" } }
    ]
  }
}
levelos’s picture

Status: Needs review » Closed (fixed)

@mh86, if you want to add that as a feature, please create a new feature request for it so we can track more granularly.

@jt55401, if you find a bug that you can replicated, post as a separate bug report.