I am using mailchimp 7.x 3.3 Module and ubercart is integrated for role selling, also I have rules module installed.

I have users subscribed to the mailchimp list, my requirement is when a user from my list purchase any order he should be unsubscribed from one list and subscribed to other mailchimp list, so that I can track the users from the list who did not purchase any order.

I am thinking of doing it using rules, In rules I have an event "when the user completes checkout", I want to add the action on same event, the action should be "unsubscribe from one list and subscribe to other list" but unfortunately I dont have any way to select the list there.

Please find the screenshot of rules interface below, help would be greatly appreciated.

This is event interface enter image description here

This is Action Interface

enter image description here


Because MailChimp doesn't want you to just subscribe people without their permission, it makes you put this into a field.

We have clients, however, who put the subscription opt-in into their Terms of Use agreement. A way around this is to create your own rule:

 * @file
 * Rules integration for the mailchimp lists module.

 * Implements hook_rules_action_info().
function mymodule_rules_action_info() {
  $items = array();
  $items['mailchimp_lists_id_user_subscribe'] = array(
    'label' => t('Subscribe or unsubscribe entity from a MailChimp list ID'),
    'parameter' => array(
      'entity' => array(
        'type' => '*',
        'label' => t('Email Address'),
        'description' => t('The email to subscribe.'),
        'wrapped' => TRUE,
        'allow null' => FALSE,
      'list_id' => array(
        'type' => 'text',
        'label' => t('MailChimp List ID'),
        'description' => t('The list ID found in the mailchimp dashboard.'),
        'allow null' => FALSE,
      'subscribe' => array(
        'type' => 'boolean',
        'label' => t('Subscribe'),
        'description' => t('True to subscribe, False to unsubscribe'),
    'group' => t('MailChimp'),
    'access callback' => 'mailchimp_lists_rules_access_callback',
    'base' => 'mymodule_rules_action_entity_subscribe',
  return $items;

 * Action callback: Subscribe an entity to a list.
function mymodule_rules_action_entity_subscribe($entity, $list_id, $subscribe) {
    $email = $entity->value();

    $choices = reset($field_info['instance']['default_value']);
    $choices['subscribe'] = $subscribe;

    if ($subscribe == 1) {
        mailchimp_subscribe($list_id, $email);
    } else {
        mailchimp_unsubscribe($list_id, $email);    

Where mymodule is the name of your custom module. This will provide the rule integration you're actually looking for.

Be careful, though: This method could get you banned from Mailchimp. It's best to combine it with a double opt-in process to prevent people from reporting subscription abuse.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.