Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Danny van Kooten

    (@dvankooten)

    Hi there,

    So, you have a redirect URL set in the plugin settings and you want to use the provided email address on the URL being redirected to?

    I would use one of the plugin hooks, write your own redirect function and then read from the hash.

    PHP (eg in your theme its functions.php)

    function my_prefix_redirect_with_email($email, $merge_vars, $form_id, $result) {
    	if($result == true) {
    		wp_redirect("/thank-you/#{$email}");
    		exit;
    	}
    }
    
    add_action('mc4wp_after_subscribe', 'my_prefix_redirect_with_email', 10, 4);

    JavaScript on thank you page

    <script>
    var email = window.location.hash.substring(1);
    </script>

    Hope that helps!

    Another option would be to set a cookie using the same hook as in my example. Or, use a session variable and print it into a JavaScript variable. Just some thoughts, this should get you going. 🙂

    Thread Starter himynameisvan

    (@himynameisvan)

    Thanks so much – I will give this a shot.

    Am a bit of a hook newbie though – I’ve added the new function and JS to the thank you page, but do I need to do anything with the plugin’s files?

    Plugin Author Danny van Kooten

    (@dvankooten)

    Nope, that’s wat hooks and filters are for – customizing the way a plugin works without having to mess with the plugin files itself. 🙂

    You can add the hooks to your theme its functions.php file, for example. That way, you can safely update the plugin to benefit from new features and bug fixes.

    Hope that helps!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Passing JavaScript variables’ is closed to new replies.