function mailchimp_lists_entity_delete in Mailchimp 7.4
Same name and namespace in other branches
- 8 modules/mailchimp_lists/mailchimp_lists.module \mailchimp_lists_entity_delete()
- 7.5 modules/mailchimp_lists/mailchimp_lists.module \mailchimp_lists_entity_delete()
- 7.3 modules/mailchimp_lists/mailchimp_lists.module \mailchimp_lists_entity_delete()
- 2.x modules/mailchimp_lists/mailchimp_lists.module \mailchimp_lists_entity_delete()
Implements hook_entity_delete().
File
- modules/
mailchimp_lists/ mailchimp_lists.module, line 59
Code
function mailchimp_lists_entity_delete($entity, $type) {
// Check for mailchimp subscription fields and unsubscribe accordingly.
$fields = field_info_fields();
foreach ($fields as $field) {
if ($field['type'] == 'mailchimp_lists_subscription' && isset($field['bundles'][$type])) {
$wrapper = entity_metadata_wrapper($type, $entity);
if (in_array($wrapper
->getBundle(), $field['bundles'][$type])) {
$instance = field_info_instance($type, $field['field_name'], $wrapper
->getBundle());
if ($instance['settings']['unsubscribe_on_delete']) {
mailchimp_lists_process_subscribe_form_choices(array(
'subscribe' => FALSE,
), $instance, $field, $entity);
}
}
}
}
}