/** * Synchronize an account in Mailchimp with users in moodle. * Do this to make sure there aren't extra addresses in Mailchimp and that the list matches users in moodle. * * @param $externaluser Mailchimp user * @param $moodleusers Array of all Moodle users * */ private function synchronize_mcuser($externaluser, $moodleusers) { // Search for the external email address in list of users $emailmatch = $this->synchronize_mcuser_ispresent($externaluser['email_address'], $moodleusers); if ($emailmatch == FALSE) { // No match was found. Delete the email from mailchimp. if (!\block_mailchimp\helper::listDelete($externaluser['email_address'])) { debugging("ERROR: Could not remove user " . $externaluser['email_address'] . " from the MailChimp list."); } else { echo "MSG: Removed " . $externaluser['email_address'] . " from the MailChimp list.\n"; } } // Do nothing if $emailmatch = TRUE and the address was found. User should be synced at this point. }