public function MailChimp_ListsTest::unsubscribe in Mailchimp 7.3
See also
Mailchimp_Lists::unsubscribe()
File
- tests/
mailchimp_lists_test.inc, line 193 - A virtual MailChimp Lists API implementation for use in testing.
Class
Code
public function unsubscribe($id, $email, $delete_member = false, $send_goodbye = true, $send_notify = true) {
$email_address = $email['email'];
$lists = $this
->loadLists();
if (isset($lists[$id])) {
if (isset($lists[$id]['data']['members'][$email_address])) {
if ($lists[$id]['data']['members'][$email_address]['status'] == 'subscribed') {
if ($delete_member) {
unset($lists[$id]['data']['members'][$email_address]);
}
else {
$lists[$id]['data']['members'][$email_address]['status'] = 'unsubscribed';
}
$this
->writeLists($lists);
return TRUE;
}
else {
$this->errorMessage = 'Could not unsubscribe ' . $email_address . ' from: ' . $id . ': not currently subscribed.';
}
}
else {
$this->errorMessage = 'Could not unsubscribe ' . $email_address . ' from: ' . $id . ': address not on list';
}
}
else {
$this->errorMessage = 'Could not unsubscribe ' . $email_address . ' from non-existant list: ' . $id;
}
return FALSE;
}