WordPress.org

Ready to get started?Download WordPress

Forums

managing cookies for a specific page (2 posts)

  1. AkivaWP
    Member
    Posted 6 months ago #

    Hi
    I'm trying to do something like this:
    I want every first time visitor to my site to be redirected to a registration page(for a mailing list, not site registration) and after the registration to be redirected to a thankyou page where a cookie will be set to prevent this process to happen on the next visit to my site.

    I created a function for creating a cookie if it doesn't exist in the functions.php file and I also call it there.

    Here are the problems I still have:
    1. I want the cookie to be set only in the thankyou page. I tried doing it with a condition in the function "is_page(3)" but the page id is not loaded yet when functions.php is loaded.

    2. Maybe this is a beginners question: how do I redirect to another page from within the wordpress page?

    *The redirection from the registarion to the thankyou page are done automatically by the mailing list registration butoon so I don't need to do anything there.

    Thanks in advance
    Akiva

  2. Timothy Jacobs
    Member
    Posted 5 months ago #

    1. You need to do this in during a hook, probably init. If you don't know about hooks and filters, you can read up about them on the WP Codex.

    2. You can use the wp_redirect() function.

Reply

You must log in to post.

About this Topic