Users unsubscribe on login

Created on 5 January 2024, 6 months ago

Problem/Motivation

I had the Mailchimp module installed on Drupal 7, it supported subscribing new users to a list when they registered. The profile page had the subscribed checkbox which was set to auto subscribe by default.

However, the company's workflow was to register directly to Mailchimp first then create the Drupal account that then syncs up to Mailchimp. So if the user already existed in the list, no subscribe action was taken by the Mailchimp Drupal module.

For one reason or another the API key for the Mailchimp module got deleted for a long time, new users to the website were added but their Drupal profile Mailchimp subscribed checkbox was marked as unsubscribed because it could not reach Mailchimp. However, since the users were added to Mailchimp first, nobody noticed. After a few thousand users, it was noticed and the API key was restored to Drupal 7.

Nothing adverse happened after this.

Last month we completed a migration to Drupal 9. Ever since that day, a bunch of users have been unsubscribed daily with the reason "N/A (Unsubscribed by admin)".
We traced it down to all the users who logged in after the upgrade and migration but who had signed up when the Mailchimp was disabled because of no API key. When you check their user profile, the subscribed field is unchecked. However it seems like, in Drupal 9, the module tries to sync users with their current Mailchimp status on login, giving the Drupal user profile field status the final say as to the subscription status.
Therefore, all users who were subscribed to Mailchimp, but not listed as subscribed in Drupal will be unsubscribed by the Maichimp API, triggered at login by their Drupal subscribed status.

I have tried to manually set the subscribed field value to one in the database to force the field to be marked as subscribed but it is totally ignored.

How do I programmatically restore the remaining incorrectly unsubscribed user profile fields to "subscribed", is there a function I can run that I can run against a list of actual subscribers that resubscribes the ones that are in the list?

πŸ’¬ Support request
Status

Active

Version

2.2

Component

Lists Module

Created by

πŸ‡ΉπŸ‡ΉTrinidad and Tobago frazras

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024