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.
The mailchimp_get_list and mailchimp_get_lists() functions do not return $list as an object that can be used to programmatically add subscribers. Developers need to manually/programmatically cast the return value from this function to an (object) in order to submit to mailchimp_subscribe_user.
Furthermore, developer needs to add mc_list_id field and label field, as well, in order for mailchimp_subscribe_user to return success.
I think that mailchimp_get_list should return an object that should be compatible with the mailchimp_subscribe_user function.
Comments
Comment #1
gregglessubscribe.
Comment #2
gregglesBetter title/version.
Comment #3
gcbmailchimp_get_lists is asking the mailchimp API for its lists & associated data: the API gives us back some arrays, and those are what mailchimp_get_lists returns: a rich data about the lists on your MailChimp instance.
mailchimp_subscribe_user doesn't take a Mailchimp list as an argument: it takes a mailchimp_lists drupal object created by the mailchimp_lists module. One of the properties on such an object is "mc_list_id". That points to the kind of list that mailchimp_get_lists is returning. This allows us to control the behavior based on various list-specific settings.
It sound like you are working outside the functionality of the mailchimp_lists module, or using mailchimp_get_lists in a way other than intended. Perhaps you want mailchimp_lists_get_available_lists?