0

I need to add a MailChimp subscriber to a specific grouping. I have no issue getting the subscriber subscribed, but can't seem to get them into a specific grouping.

This is what I have:

// ENTER INTO MAILCHIMP

$newsletter =  $_POST['newsletter'];
$newsletter = 'yes';                 

if ($newsletter = "yes") {
    $MailChimp = new \Drewm\MailChimp('api');
    $result = $MailChimp->call('lists/subscribe', 
                array(
                        'id' => 'listnumber',
                        'email' => array('email'=> $_POST['usersEmail']),
                        'merge_vars' => array(
                                            'FNAME'=>$_POST['usersName'], 'LNAME'=>$_POST['usersLastName'],
                                            'groupings' => array(
                                                                'id' => 494281,
                                                                array(
                                                                    'name'=>'KeepBoard',
                                                                    'groups' => 'KeepBoardUsers'
                                                                )
                                                            )
                                            ),
                                            'double_optin'      => false,
                                            'update_existing'   => true,
                                            'replace_interests' => false,
                                            'send_welcome'      => false
                    ));
    print_r($result);
} 

Also I am not entirely sure where to grab the listing id. I can't seem to find documentation. I worked off the URL. But I don't think that is right because that is the id for all groupings.

Suhaib Janjua
  • 3,538
  • 16
  • 59
  • 73
looloobs
  • 761
  • 2
  • 11
  • 24
  • Hi there i think i found a few things 1.http://stackoverflow.com/questions/18450896/add-users-to-interest-group-via-mailchimp-api-v2-0 2. http://stackoverflow.com/questions/20266081/subscribing-users-with-groups-through-mailchimp-2-0-api – Billy Price Mar 16 '15 at 22:06
  • Thanks sure enough I found the answer in those. Apparently I need to learn how to better search stackoverflow because I had looked at several other entries. – looloobs Mar 17 '15 at 01:07

1 Answers1

0

For those that have this problem this was the issue. The groups have to be an array, even for a single group.

looloobs
  • 761
  • 2
  • 11
  • 24