Tweak the WordPress Live Plugin to Exclude Your IP Address

John Chow recently posted about the WordPress Live plugin from Headzoo, which allows you to watch your blog activity in real-time. He even included a cool video that shows the sickening amount of traffic that he gets on his site. Check out the video here.

Being a stat junkie myself, I thought I would install the Live plugin and see it in action for myself. I must admit that I was totally impressed with Live from the instant I installed it. I’ll definitely be adding this plugin to my list of recommended WordPress plugins.

Since I don’t have people visiting my blog in droves like John Chow does, I immediately noticed that Live was showing all my personal activity as well as that of my visitors. I don’t want to see my activity, because I already know which pages I visit and which posts I’ve commented on, etc. I want to see everyone else’s activity, so I tweaked the Live plugin to support IP address filtering.

Support for IP Address Filtering

The changes I made to the WordPress Live plugin allow you to filter the live activity using your dynamic WAN IP address and/or one or more fixed IP addresses.

Installation Instructions

If you are already running WordPress Live on your site, deactivate the Live plugin before continuing. Click on the ‘Deactivate’ link in the ‘Plugins’ section of your WordPress admin area.

Download and install the WordPress Live modifications. Inside the zip file, there is a folder named live0.4.1, which contains some files and sub folders inside of it.

Upload the live0.4.1 folder to your /wp-content/plugins folder on your web host using your favorite FTP client program.

If you are already running Live version 0.4.1, overwrite the existing files when prompted by your FTP client.

Once you have uploaded the Live folder to your web host, activate the plugin by clicking the ‘Activate’ link in the ‘Plugins’ section of your WordPress admin area.

Configure IP Filtering

Before you make any changes to the Live plugin files, make sure you deactivate the WordPress Live plugin.

In order to change the IP filtering behavior, you have to edit the WordPress Live PHP file. The easiest way to do this is to use the Plugin Editor in your WordPress admin area. To use the Plugin Editor, login to your WordPress admin area and click ‘Plugins’ from the main menu, then click the ‘Plugin Editor’ link. On the right-hand side of the screen, you’ll see the list of installed plugins.

Click on the link labeled ‘Live’ to load the PHP file in the editor.

Scroll to the very bottom of the file and find these two lines of code:

$ip_address_filter = $remoteIP;
$Live = new Live0_4_1($wpdb, $table_prefix, $ip_address_filter);

These are your options for custom IP filtering:

Dynamic WAN IP Address

The dynamic WAN IP address is the IP address that’s given to you by your Internet service provider. Depending on your Internet service, you may either have the same address all the time or your provider may give you a different address from time to time.

This setting allows the WordPress Live plugin to detect what address you are coming from and automatically filter the results, even if your WAN IP address changes every day. This is the default setting.

Change the $ip_address_filter variable to this:

$ip_address_filter = $remoteIP;

Fixed IP Addresses

To filter fixed IP addresses, you’ll need to change the $ip_address_filter variable to use a comma-delimited list of addresses, like this:

Single Address: $ip_address_filter = "68.99.116.151";

Multiple Addresses: $ip_address_filter = " 68.99.116.151,68.12.155.111";

Dynamic and Fixed Addresses

To filter your WAN IP address plus additional fixed IP addresses do this:

$ip_address_filter = $remoteIP.",68.99.116.151";

Disable IP Filtering

To disable IP address filtering all together, do this:

$ip_address_filter = "";

Once you’ve made your changes, click the ‘Save’ button and activate the WordPress Live plugin.

Please contact me if you have any questions or problems with the new code.

Download WordPress Live with IP Filtering

If you enjoyed this post, make sure you subscribe to my RSS feed!

8 Comments so far

  1. Grace on June 29th, 2007

    Lucky me– I like looking at my stats too… Even though I try not to. :D

  2. Donovan on June 29th, 2007

    It’s an addiction for me. We need a support group or something.

    Enjoy!

  3. Grace on June 29th, 2007

    Exactly. :)

  4. jorgeeporgee on June 29th, 2007

    Now all I need is a HOTTT blog.

  5. Donovan on June 29th, 2007

    I see you found the post Jorge, good job! I’m really surprised.

    You still haven’t dugg it yet…

    Jorge is a friend of mine, and he bet me he could find this post on Digg without knowing the subject or who dugg it. I didn’t think he could, but he did. Damn.

  6. BR on August 17th, 2007

    I think this is a great plugin, but the plugin I really need is a post ip to comment.

    Basically I need when someone post a comment to tac their ip to the bottom of the comment, is this possible or heard of?

  7. Donovan on August 17th, 2007

    You can use the following PHP to display the comment author’s IP address:

    <?php comment_author_IP(); ?>

    Just insert this code anywhere in the comment loop in your comments.php file.

    I added this code directly after the <?php comment_author_link() ?> and enclosed it in parenthesis like this:

    (<?php comment_author_IP(); ?>)

    If you need more details, feel free to contact me using the contact form.

  8. BR on August 17th, 2007

    Donovan- you rock. Worked like a charm. Trackback to you forthcoming.

Leave a reply

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word