Problem/Motivation
Currently, it's possible to use an alter hook to update the $mergevars
with additional data, but it's not currently possible to do the same with the Interest groups.
I'm updating a site that was developed prior to Interest Group support being added. It instead used a taxonomy to set extra $mergevars
checkboxes, and these were then used to create Segments in Mailchimp.
Unfortunately our client has deleted and re-created their list, and Mailchimp no longer seems to support creating new MergeVars checkboxes, in favour of using Interest Groups instead.
This has left me in an awkward situation where I have data in their Drupal taxonomy fields which is disconnected from Mailchimp, with no easy way to copy it over.
Proposed resolution
Add a new mailchimp_lists_interest_groups
hook to allow interest groups to be populated from other form field data.
API changes
Added mailchimp_lists_interest_groups
hook.
/**
* Alter interest groups before they are sent to Mailchimp.
*
* @param array $interests
* The current interest groups.
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity used to populate the interest groups.
* @param string $choices
* The entity form submission data.
*
* @ingroup mailchimp
*/
function hook_mailchimp_lists_interest_groups_alter(array &$interests, EntityInterface $entity, array $choices) {
}