I'm trying to direct new site visitors to a custom registration page for the their first visit only. The registration collects detailed information relating to an upcoming event, it is not designed to register the visitor as a user of the WordPress installation.
The registration page contains a Gravity form which when submitted redirects to a thank you page.
I would like to know the correct way to place a cookie in WordPress only when the visitor lands on the thank you page.
Thanks in advance.
NB:
I should also say that I've added the following to the functions.php file:
/* SET NEW USER COOKIE */
function set_newuser_cookie() {
if (!isset($_COOKIE['newtcpa_visitor'])) {
setcookie('newtcpa_visitor', 1, time()+3600*24*100, COOKIEPATH, COOKIE_DOMAIN, false);
}
}
add_action( 'init', 'set_newuser_cookie');
I'm unsure about COOKIEPATH & COOKIE_DOMAIN. I've tried the following settings, but I'm not having much luck at isolating the WP template/page:
setcookie('newtcpa_visitor', 1, time()+3600*24*100, '/', '.mydomain.com', false);
and
setcookie('newtcpa_visitor', 1, time()+3600*24*100, '/', '.mydomain.com/thank-you/', false);
Apologies for the multiple edits... first post on WordPress Answers