function constant_contact_user_operations_unsubscribe_and_delete in Constant Contact 6.3
Same name and namespace in other branches
- 7.3 constant_contact.module \constant_contact_user_operations_unsubscribe_and_delete()
Mass unsubscribe and delete option
1 string reference to 'constant_contact_user_operations_unsubscribe_and_delete'
- constant_contact_user_operations in ./
constant_contact.module - Alter bulk user operations to delete and unsubscribe
File
- ./
constant_contact.module, line 761
Code
function constant_contact_user_operations_unsubscribe_and_delete($accounts) {
$cc = constant_contact_create_object();
if (!is_object($cc)) {
return;
}
// use the API to remove these users then delete their drupal account
foreach ($accounts as $uid) {
$account = user_load(array(
'uid' => (int) $uid,
));
if ($account !== FALSE) {
// Skip unsubscribing user if they are already unsubscribed.
// find contact
$contact = $cc
->query_contacts($account->mail);
if ($contact) {
$cc
->delete_contact($contact['id']);
}
user_delete(array(), (int) $uid);
}
}
}