Last active
February 27, 2017 09:57
-
-
Save evrpress/ecb2f56d10f08ead549d2e3a7b20cad7 to your computer and use it in GitHub Desktop.
List only Unsubscribe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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