How does this hook work? I need to insert an action into a page specified within the wp_head() or wp_footer() function.
But when you add the action in wp_head (add_action ( 'wp_head', 'mymail_change_list_segment');), the variables in question are empty or the whole thing's not working.
So I added my function to the header.php and footer.php and it still doesn't work.
When I put it directly into page.php, it works.
Can someone help me?
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);
}}