webform_mailchimp 7.x-4.x-dev does not handle interest groups appropriately per API v.3. Currently, no components exist to map the group name to it's corresponding Mailchimp ID. Reworking the way groupfields are created and using the group ID as opposed to the group label seems to fix the issue.

Mailchimp Webform Field Config:

Mailchimp interest fields:
"Mailchimp Interest Group Name"|"Webform Field Key" (checkboxes or dropdown)

Webform Options Field:
"Mailchimp group ID"|"Human Readable Label"

Currently running:
mailchimp 7.x-4.7
webform_mailchimp 7.x-4.x-dev
webform 7.x-4.14

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

AlejandroSalinas9294 created an issue. See original summary.

daniyar.seferov’s picture

Same patch with pre-built option list of Mailchimp groups [list_name]: [group_name]

AlejandroSalinas9294’s picture

Status: Active » Needs review
Baysaa’s picture

Status: Needs review » Reviewed & tested by the community

The patch at #2 works. Adds a nice mailchimp interest groups "Pre-build option list" to a Webform "Select options" type form component.

The only thing for me was that our organisation uses a lot of hidden interest groups, and the mailchimp_get_lists() function skips "hidden" interest groups which was not ideal for my use-case. The only way to change that was for me to copy the mailchimp_get_lists() function and paste it into this module as webform_mailchimp_get_lists(), and remove the logic to skip hidden interest groups.

I could've added this as a configuration, but this module doesn't have any config forms at the moment, and making a whole new interface just for 1 checkbox seemed like an overkill, so I'm just going to continue using my own patch for my own use-case and not post it here.

millionleaves’s picture

Patch in #2 works for me, and the "Pre-built option list" is very handy. I don't have any hidden interest groups on this particular site.

I'm assuming the interest group IDs are now required (by the Mailchimp API) for interest group fields to function. I'm not sure where I would have obtained those IDs from without this patch. Would be good to see it committed, and have some instructions on how to use the Pre Built Option" feature documented on the main module page.

achton’s picture

The patch in #2 was not formatted as a p1 patch, so adding an updated patch here which applies cleanly. No change otherwise.

d.bipes’s picture

Baysaa,

Do you mind sharing the code you changed to do this?

meez’s picture

I applied patch #2 and I can see the file webform_mailchimp.module has been changed. But it looks like on the Webform configuration page I don't see any changes. I also get this error: Status code 400. "400: Invalid Resource - Invalid interest ID: '77927'."?

In webform_mailchimp field configuration I have (see attachment):

Mailchimp merge fields:

NAME|field_naam
EMAIL|field_email

Mailchimp interests fields:
Gender|field_sexe

In webform component radio buttons field_sexe I have (see attachment):
Man
Woman

What I am doing wrong here?

johanvdr’s picture

I see in Comment #2 that a pre-build list can be build with Interest Groups available in the checkbox/dropdown component. That works ok. Is that all you need?
The pre-build list gets the key/value pairs.

[INTEREST GROUP ID]|[INTEREST GROUP NAME]
[INTEREST GROUP ID]|[INTEREST GROUP NAME]

Do you still need to do add anything than to Mailchimp interests fields in the webform mailchimp component (or is that already taken care off)?

branram’s picture

I've tried rolling the two versions of this patch in #2 and #6 but neither seem to be populating any interest group lists in the mailchimp field webform component settings. The "Mailchimp interests fields" still an open text area field. And unfortunately since Mailchimp decided to sunset their developer playground, I don't have an easy way to manually find the group id I need. I'm not sure if I'm doing something wrong or if there have been new requirements from Mailchimp since this patch was created.