counterize patch 2: excluding users, the first step
Posted in WordPress on March 31st, 2006 by Johan Huysmans – 1 CommentAdding a counter on your site is great. But if you want to get the real number of visitors you may not count your own pagehits.
In the counterize plugin is an excludelist where you can add your own ip. But I’m always on different locations and what if someone else from the same network visits your website… it doesn’t get counted.
I know 1 thing… If I visit my blog, I’m already logged in (he remembers my login). So what I made is an extra check before the page-hit get logged. If I’m logged in, it doesn’t need to be counted.
Adding these simple lines does the trick (added them at line 631)
# let's check it is a logged in user.
# If he's logged in, we don't count him.
if ($checkval == 0) {
global $user_ID;
get_currentuserinfo();
if('' == $user_ID)
$checkval=0;
} else {
$checkval=1;
}
This is hard coded, but I will add an option to the admin webinterface of counterize that can enable or disable this option and maybe add an textfield so you can decide which user doesn’t need to be logged.
Enjoy ! You can find the patchfile here.