function mailchimp_webhook_delete in Mailchimp 7.5
Same name and namespace in other branches
- 8 mailchimp.module \mailchimp_webhook_delete()
- 7.3 mailchimp.module \mailchimp_webhook_delete()
- 7.4 mailchimp.module \mailchimp_webhook_delete()
- 2.x mailchimp.module \mailchimp_webhook_delete()
Wrapper around MailchimpLists->deleteWebhook().
Return value
bool TRUE if deletion was successful, otherwise FALSE.
2 calls to mailchimp_webhook_delete()
- MailchimpListsTestCase::testDeleteWebhook in modules/
mailchimp_lists/ tests/ mailchimp_lists.test - Tests deletion of a webhook.
- mailchimp_lists_webhook_form_submit in modules/
mailchimp_lists/ includes/ mailchimp_lists.admin.inc - Submit handler for mailchimp_lists_webhook_form().
File
- ./
mailchimp.module, line 1525 - Mailchimp module.
Code
function mailchimp_webhook_delete($list_id, $url) {
try {
/* @var \Mailchimp\MailchimpLists $mc_lists */
$mc_lists = mailchimp_get_api_object('MailchimpLists');
if (!$mc_lists) {
throw new MailchimpException('Cannot delete webhook without MailChimp API. Check API key has been entered.');
}
$result = $mc_lists
->getWebhooks($list_id);
if ($result->total_items > 0) {
foreach ($result->webhooks as $webhook) {
if ($webhook->url == $url) {
$mc_lists
->deleteWebhook($list_id, $webhook->id);
return TRUE;
}
}
}
return FALSE;
} catch (Exception $e) {
watchdog('mailchimp', 'An error occurred deleting webhook for list @list. "%message"', array(
'@list' => $list_id,
'%message' => $e
->getMessage(),
), WATCHDOG_ERROR);
return FALSE;
}
}