Search code examples
wordpressmaintenance-mode

Wordpress 3.0 and maintenance mode - A Problem


For some reason it seems that WP3.0 is bugged with everything relate to maintenance-mode.

The 2 maintenance-mode plugins (maintenance-mode & wp-maintenance-mode) cause the following problems:

  1. wp-maintenance-mode doesn't allow u login as an admin. He just blocks you at the wp-login page.
  2. wp-maintenance-mode even doesnt influence a thing.

The same thing happend to me when I tried to write it by myself using this tutorial.

This line worked perfect and showed the built-in maintenance screen, but when I tried to add the condition for is_user_logged_in(), the mode stops working, letting you see the cliend & back end, when u r logged in or logged out.

What can I do? Thanks for all the answerers.


Solution

  • The is_user_logged_in() function the tutorial provides is pretty terrible, and it's why you're getting false positives for being 'logged in'.

    Instead, load the pluggable file that contains the default WordPress is_user_logged_in() function;

    require_once (ABSPATH . WPINC . '/pluggable.php');
    if ( ! stristr($_SERVER['REQUEST_URI'], '/wp-admin') && ! stristr($_SERVER['REQUEST_URI'], '/wp-login.php') && ! is_user_logged_in() )
        $upgrading = time();
    else
        $upgrading = 0;