- Issue created by @ecvandenberg
- πΊπΈUnited States en-cc-org
Same issue; mailchimp 2.2.2 on Drupal 9.5.10. Summary of my test findings:
The mailchimp subscription field stays NULL unless/until the user is manually opened for edit and saved (with or without any changes made to the user). Manually opening a user for edit pulls in the data from Mailchimp; for example you'll see the checkbox is automatically selected and interest groups populated IF the user's email exists in Mailchimp AND is a subscriber. If the user's email doesn't exist in Mailchimp OR exists there but is not subscribed, the checkbox will not be selected. Manually saving that user populates the field in the database, after which the user's profile will display either Subscribed or Not Subscribed (instead of being NULL). AFTER this manual open/save, the module is THEN able to update subscription status when any further changes are made on either side. How to avoid manually opening/saving thousands of users? Neither VBO nor Feeds is able to initially bulk populate the NULL mailchimp subscription field.
Searching the issue queue, found an old/D7 script, so I updated it for D9.
1. Load the user via \Drupal::entityTypeManager()->getStorage('user')->load($i); or \Drupal\user\Entity\User::load($i);
2. Make any change (for example, add a role)
3. Save the user via save();
The script updates & saves the user BUT the mailchimp subscription field is NOT updated.What does the manual open/save do that allows it to initially access Mailchimp data, and how can I incorporate programmatically?
- πΊπΈUnited States amh5514
The exact situation we're going through. About 13K users and the field is null. New signups are being recorded as they should, but the older accounts are not synced properly with their MC accounts. If we edit/save, then they resync, and the information is updated.
- πΊπΈUnited States en-cc-org
I ended up creating a browser automation script to do the initial sync. I used UIPath but I'm sure anything that can use a browser to programmatically load a user in edit mode & save will work. I had to babysit it as it ran through thousands of users, sometimes timing/erroring out, but better than hours and hours of manual work (or incorrect data).