Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
We have a site with a significant userbase. About a quarter of these users opt into our lists (via Content Profile settings, not via Interest Groups).
With a few small changes, I think Mailchimp module can support allowing external modules to specify (via standard Drupal hooks) which users should be subscribed to which lists. These changes should not have any impact on existing functionality.
Comment | File | Size | Author |
---|---|---|---|
#1 | mailchimp-1125490-modularise_subscription_interface.patch | 2.05 KB | xurizaemon |
Comments
Comment #1
xurizaemonThis patch to mailchimp.module makes two changes -
1) mailchimp_user() loads the required lists against the user in hook_user(). It maintains the existing behaviour of setting lists according to the assigned roles.
2) mailchimp_cron() checks $account->mailchimp_lists instead of $account->roles.
(array_intersect_key() is PHP5, if mailchimp doesn't already require php5 I can provide an alternative).
By utilising the user object, we allow other modules to interact with the user's subscribed lists in hook_user(), and we can do things like this.
The above code is part of an external module for a site which uses content_profile, and has fields "content_profile_a" and "content_profile_b".
Having "Y" for either of these fields means the site user should be included in required list subscriptions; otherwise they are unsubscribed.
We set those lists to "required" for 'authenticated user' role, then decide based on properties of the user (or their profile) whether the user will be subscribed or not.
Comment #2
nrackleff CreditAttribution: nrackleff commented“And now our watch [for support of the 6.x version of the MailChimp module] has ended…” With the end of Drupal 6 support, I’m sad to say we too must turn the page.
Fret not! The 7.x-4.x and 8.x versions come highly recommended. Both are using Mailchimp’s new API 3.0 and are being actively maintained. “What is dead may never die, but rises again, harder and stronger!”