function constant_contact_user_operations_unsubscribe in Constant Contact 7.3
Same name and namespace in other branches
- 6.3 constant_contact.module \constant_contact_user_operations_unsubscribe()
- 6.2 constant_contact.module \constant_contact_user_operations_unsubscribe()
Callback function for admin mass unsubscribe users.
1 string reference to 'constant_contact_user_operations_unsubscribe'
- constant_contact_user_operations in ./
constant_contact.module - Implements hook_user_operations().
File
- ./
constant_contact.module, line 804
Code
function constant_contact_user_operations_unsubscribe($accounts) {
$cc = constant_contact_create_object();
if (!is_object($cc)) {
return;
}
// Use the API to remove these users.
foreach ($accounts as $uid) {
$account = user_load($uid);
// Skip unsubscribing user if they are already unsubscribed.
if ($account !== FALSE) {
user_save($account, array(
'cc_newsletter' => 0,
));
// Find contact
$contact = $cc
->query_contacts($account->mail);
if ($contact) {
$cc
->delete_contact($contact['id']);
}
}
}
}