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

greggles’s picture

subscribe.

greggles’s picture

Title: mailchimp_get_list and mailchimp_get_lists » Make mailchimp_get_list and mailchimp_get_lists return data that can be passed to mailchimp_subscribe_user
Version: 7.x-2.6 » 7.x-2.x-dev

Better title/version.

gcb’s picture

Status: Active » Closed (works as designed)

mailchimp_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?