Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
List only Unsubscribe
function mailster_lists_only_unsubscribe($subscriber_id, $campaign_id){
//unsubscribe user if campaign doesn't exists or isn't set
if(!mailster('campaigns')->get($campaign_id)) return;
$subscriber = mailster('subscribers')->get($subscriber_id);
if($subscriber){
//change back to subscribed (silently)
mailster('subscribers')->change_status($subscriber_id, 1, true);
//get lists from the campaign
if($lists = mailster('campaigns')->get_lists($campaign_id, true)){
//unassign those lists
mailster('subscribers')->unassign_lists($subscriber_id, $lists);
}
}
}
add_action('mymail_unsubscribe', 'mymail_lists_only_unsubscribe', 20 , 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment