Password-protect Blog
-
I want to know if you could implement an option in WordPress where you can password-protect your own blog to a specific username and password if you don’t want anybody to find out. I already have this but I want this to be an option on WordPress. Here is the code I’m using:
wp-blog-header.php top lines
$pwd = "mysecretpwd";
if($_COOKIE["authpwd"] != $pwd) {
if(!ereg("/wp-admin/edit.php", $PHP_SELF)) {
if ($_SERVER['PHP_AUTH_PW'] != $pwd) {
header('WWW-Authenticate: Basic realm="Password-protected blog."'); //Actually... this is different on my wp-blog-header.php.
header('HTTP/1.0 401 Unauthorized');
echo 'Please email [email protected] for password';
exit;
}
}
}
@error_reporting(0);
setcookie("authpwd",
$pwd,time()+60*60*24*30,
"/",".yourdomain.com");
- The topic ‘Password-protect Blog’ is closed to new replies.