/** * listDelete * Delete a user from the list. * * @param $email_address the email address to delete * */ public static function listDelete($email_address) { global $CFG; $listid = $CFG->block_mailchimp_listid; //First obtain the memberID for the email address. $memberid = helper::getMemberID($listid, $email_address); $method = "lists/" . $listid . "/members/" . $memberid; if (!($api = new \DrewM\MailChimp\MailChimp($CFG->block_mailchimp_apicode))) { debugging("ERROR: Unable to create mailchimp wrapper object \\DrewM\\MailChimp\\MailChimp."); return false; } $result = $api->delete($method); if ($result !== false) { debugging("ERROR: Unable to remove user " . $email_address . " from mailchimp, method: " . $method . "\nResult: " . print_r($result) . "\n"); return false; } return true; }