Last active
February 27, 2017 09:58
-
-
Save evrpress/11eb34aa37de0a6b4d81f73a790034ab to your computer and use it in GitHub Desktop.
Assigns a subscriber to a certain list if a certain link has been clicked
This file contains 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 my_add_user_to_list_after_click_on_link ( $subscriber_id, $campaign_id, $target, $index ){ | |
$link = 'http://example.com'; | |
$list_id = 123; | |
$remove_from_old_lists = false; | |
if( $link == $target ){ | |
mailster('subscribers')->assign_lists($subscriber_id, $list_id, $remove_from_old_lists); | |
} | |
} | |
add_action( 'mailster_click', 'my_add_user_to_list_after_click_on_link', 10, 4); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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:
add_action('wp_head','mymail_change_list_segment');
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);
}}