aelvan/mailchimp-subscribe-craft

Assigning interest groups

Closed this issue · 1 comments

Hello there,

I'm currently working on my own module where users got subscribed automatically once there account is approved. This all works but I have a hard time to assign them to a certain interest group.

 $msPlugin->mailchimpSubscribe->subscribe('test@test.be', 'thisIsNotALegitId', [
                    'email_type' => 'html', 
                    'language' => 'nl',
                    'merge_fields' => [
                        'FNAME' => 'test',
                        'LNAME' => 'Ipsum',
                    ],
                    'interests' => array(
                        '07b70ce221' => false,
                        '942bfd12ce' => true,
                        'ff0803b086' => false
                        )
                ]);
           

All changes got applied except the interest group ones.
Hope somebody can help.

It's not intuitive, but the interest IDs actually needs to be in an array indexed by their group's title (don't ask me why), so something like this should work:

$msPlugin->mailchimpSubscribe->subscribe('test@test.be', 'thisIsNotALegitId', [
    'email_type' => 'html', 
    'language' => 'nl',
    'merge_fields' => [
        'FNAME' => 'test',
        'LNAME' => 'Ipsum',
    ],
    'interests' => [
       'Interest group title' => ['942bfd12ce'],
    ],
]);