I've installed the Mailchimp plugin and added a field to my user profile called field_mailchimp_test and I'm attempting to subscribe all current Drupal users to this list programmatically (since it seems this feature was taken out of the 7.3 branch for whatever reason).

I attempted this code:

function module_mailchimp_subscribe() {
  $users = entity_load('user');
  foreach ($users as $key => $user) {
    if ($user->uid != 1 && !empty($user->mail)) {
      $edit = array(
        'field_mailchimp_test' => array(
          'und' => array(
            0 => array(
              'value' => true
      var_dump(user_save($user, $edit)); exit;

Which returns a user object with the field_mailchimp_test field set to true, which I would think would subscribe them, but when checking the users page and/or var_dumping the user object, the field is no longer set to true.

So my question is either what is wrong with my code that it's not subscribing users, or what is a different (easier/more sensical) way of doing this?

1 Answer 1


I'm pretty sure the MailChimp module doesn't actually store user subscriptions in the Drupal database, it picks up data from the MailChimp API when required.

What worked for me was to export all my Drupal users and import them into MailChimp through their website. This is fine for a once-off, and you should be able to handle new and updated users directly through the module.

  • We ended up using the API to batch subscribe all the users. Not idea, but it got the job done.
    – Samsquanch
    Nov 14, 2014 at 0:45
  • Yeah that would work. I'm not sure what 'ideal' would be, that seems pretty close to me.
    – Darvanen
    Nov 14, 2014 at 0:55
  • I'd say ideally the module itself would have the ability to subscribe all existing users to a list (and from what I've read it seems like this was a feature in the 7.2 branch). It's a bit of a pain if you want to integrate mailchimp into your system long after it was first built with newly created lists that all of those people need to be in.
    – Samsquanch
    Nov 14, 2014 at 1:03
  • Fair enough! =)
    – Darvanen
    Nov 14, 2014 at 1:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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