specific template for first visit with cookie

Plugin Name: first-visit-template
Description: Loads a welcome.php template in theme directory if it is the first visit (the function is not lauched if you’re logged as admin), and writes a cookie so it’s shown only once.
Author: G.Lachance
Author URI: http://tinyurl.com/
Credits: Based upon the “Welcome Visitor! Reloaded” plugin from Alaeddin, which is largely based upon the original Welcome Visitor! plugin by Kaf (http://guff.szub.net/)
which was released under the GNU General Public License.
Version: 1


//for testing your template, uncomment line 30.

function welcome_visitor_reloaded() {

if(is_new_visitor()) {
$tpl_file = TEMPLATEPATH . ‘/welcome.php’;
if ( file_exists($tpl_file) ) {

function is_new_visitor()

//return true; //uncomment this for testing.

global $visits;

if (!is_admin())
if (isset($_COOKIE[‘visits’]))
$visits = $_COOKIE[‘visits’] + 1;
$visits = 1;

$url = parse_url(get_option(‘home’));
setcookie(‘visits’, $visits, time()+60*60*24*365, $url[‘path’] . ‘/’);
else return false;

return $visits == 1;

add_action(‘template_redirect’, ‘welcome_visitor_reloaded’);


specific template for first visit