When cron runs it only subscribes users in the mailchimp_user table if they are active (status = 1), however it still changes their status in mailchimp_user from pending to current.

This doesn't seem like the best behaviour.

  1. A member signs up to a site that requires admin approval for users.
  2. Cron runs and rightly doesn't add them to a list.
  3. The admin approves their account.
  4. Cron runs but the member is not added to the list because their status in mailchimp_user is "current"

There are two solutions to this in mailchimp_cron()

One, change the initial query to omit inactive users:

$sql = "SELECT m.uid FROM {mailchimp_user} m
              LEFT JOIN {users} u ON (m.uid = u.uid)
            WHERE m.status = '%s'
              AND u.status = 1";

Two, move the db_query that changes the status to "current" beneath the if statement:
From:

while ($row = db_fetch_object($result)) {
        if ($account = user_load(array('uid' => $row->uid))) {
          db_query('UPDATE {mailchimp_user} SET status = \'%s\' WHERE uid = %d', MAILCHIMP_USERSTATUS_CURRENT, $account->uid);

          // We don't update people if their status = 0 (but perhaps we could unsubscribe them?)
          if ($account->status) {
            foreach ((array)$lists as $key => $list) {

To:

while ($row = db_fetch_object($result)) {
        if ($account = user_load(array('uid' => $row->uid))) {

          // We don't update people if their status = 0 (but perhaps we could unsubscribe them?)
          if ($account->status) {
            db_query('UPDATE {mailchimp_user} SET status = \'%s\' WHERE uid = %d', MAILCHIMP_USERSTATUS_CURRENT, $account->uid);
            foreach ((array)$lists as $key => $list) {

Comments

levelos’s picture

Status: Active » Fixed

Thanks Sarenc, I went with #1, which also allows us to remove the conditional block. http://drupal.org/cvs?commit=470464

Status: Fixed » Closed (fixed)

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