Sometimes you just want to have a blog that only you and a select group have access to, with no crazy bells and whistles.
I’m not releasing this as a plugin because it’s so darn simple but you can pretty much just copy and paste the following code into a folder within your plugins directory and then activate it under ‘Plugins’.
Anyone not logged in is directed to the login page.
<?php
/*
Plugin Name: Tumble Coyote
Plugin URI: http://tumbledesign.com/
Description: Protects the Tumble Cave
Version: 0.0.0.1
Author: Tumble Design
Author URI: http://tumbledesign.com
*/
?>
<?php
/* =Setup
* -------------------------------------------------*/
if(!class_exists("Coy")){
class Coy{
function Coy(){
}
function protect(){
if((!(current_user_can('read')) && (strpos($_SERVER['REQUEST_URI'], 'wp-login.php') === false))){
wp_redirect('/wp-login.php');
exit;
}
}
}
}
if(class_exists("Coy")){
$coy = new Coy();
}
/* =Hooks
* -------------------------------------------------*/
if(isset($coy)){
add_action('init', array(&$coy, 'protect'));
}
