Skip to content

Instantly share code, notes, and snippets.

@MikeNGarrett
Created February 20, 2013 21:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MikeNGarrett/5000022 to your computer and use it in GitHub Desktop.
Save MikeNGarrett/5000022 to your computer and use it in GitHub Desktop.
Allow WordPress users to log in to wp-admin and wp-login.php while in maintenance mode. Stick this in your web root to put your site into maintenance mode.
<?php
function is_user_logged_in() {
$loggedin = false;
foreach ( (array) $_COOKIE as $cookie => $value ) {
if ( stristr($cookie, 'wordpress_logged_in_') )
$loggedin = true;
}
return $loggedin;
}
if ( ! stristr($_SERVER['REQUEST_URI'], '/wp-admin') && ! stristr($_SERVER['REQUEST_URI'], '/wp-login.php') && ! is_user_logged_in() )
$upgrading = time();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment