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?

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);
  • 1
    The proper place would be the functions.php, but which variables are empty? $_COOKIE? May 5, 2015 at 16:24

1 Answer 1


The first thing to do is ensure that your template's header.php and footer.php files contain, respectively, calls to wp_head() and wp_footer(). Without those functions, no actions hooked to wp_head / wp_footer will work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.