WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a page like a welcome page which should be visited only once by each subscriber. After registration, they will redirected on my welcome page. Then I want that page not be available on same user for the second time, if the will try, I want them to be redirected. Is this possible?, should I use plugin? Thanks. :)

share|improve this question
What you want probably isn't strictly possible. If you set a cookie, there is always a chance that the user has deleted it. You can work around this for logged in users by tracking them in the db, but even together you don't have 100% certainty that the users will not get back to that "one time only" page. That may be the best you can do though. – s_ha_dum Dec 10 '12 at 14:56
up vote 1 down vote accepted

As mentioned in a comment above the cookie solution will not totally do the trick. If it's ok that they can revisited the welcome page from a different browser or if they delete cookies. This is fine.

If not I would use the database. I think easiest would be to regard the time the user was registered.

Like if the user registered within the last 60 minutes offer the welcome page. If not forward somewhere else.

This solution does not require you to alter the database and does not have the drawbacks of the cookie. If you want to offer a limited time offer for newly registered this might be a good way. You can even combine this with the cookie. That way you make sure the visitor can only see it once on his first device. And if he logs in on his second device more than 60 minutes later he will not see it either.

share|improve this answer
Thanks for clarifying, makes more sense. Thanks @Christoph – markyeoj Jun 28 '14 at 5:24

Following code should work. Please replace page ID and redirected url with your own.

add_action( 'send_headers', 'welcome_redirect' );
function welcome_redirect() {
    global $wp;
    // check if it is a welcome page
    if($wp->query_vars['p'] == 1){
            setcookie("welcome_visited", 1, time()+3600000, "/");   // set cookie 
        else {
            header('Location: '.get_site_url()); // redirect to homepage
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.