Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Assigns a subscriber to a certain list if a certain link has been clicked

This comment has been minimized.

Copy link

@ioniacob ioniacob commented Sep 29, 2016

Your code don't work for my.
I tested with the following code for cancel subscripton for list 1 and suscribe to list 2 if the user click a button:

function mymail_change_list_segment() {
if ( is_page(711) ) {
$userhash = isset($_COOKIE['mymail']) ? $_COOKIE['mymail'] : NULL;
$subscriber = mymail('subscribers')->get_by_hash($userhash, true);
$user_mail = $subscriber->email;
$lists = 1;
global $user_mail, $userhash, $lists, $subscriber;
$subscriber_ids = mymail('subscribers')->add(array(
'email' => $user_mail,
'status' => 1,
), $overwrite = true );
mymail('subscribers')->assign_lists($subscriber_ids, $lists, $remove_old = true);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment