I'm trying to create a simple module that subscribes someone to a list when they check a checkbox on a form. My problem comes when trying to load Mailchimp lists:
There seems to be two IDs for lists, a 10 character code (which I'm assuming is Mailchimp's ID) and what I think is the entity ID (eg. 1, 2). In a configuration screen I'm using mailchimp_get_lists() - the only ID returned here seems to be the 10 character code. Later in my code I need to load the list selected in the configuration screen to use with mailchimp_subscrible_user(). For this I'm using mailchimp_lists_load(). The problem is that this function seems to take the entity ID rather than the 10 character code which has been saved from the configuration screen.
Here's the relevant code:
Creating the #options for the configuration form:
//Get all the Mailchimp Lists
$lists = mailchimp_get_lists();
//Create an array of list IDs and Names
foreach($lists as $list) {
$options[$list['id']] = $list['name'];
}
Using the list ID stored in the configuration screen to load a mailchimp list:
$list_id = variable_get('commerce_mailchimp_select_list');
$list = mailchimp_lists_load($list_id);
I'm not entirely sure what I'm asking here - I guess I just can't understand why one or the other IDs isn't used in all cases. I'm sure there is a rational explanation and if so how should I be doing this instead?
Thanks in advance.
Comments
Comment #1
Perignon CreditAttribution: Perignon as a volunteer commented