• mx760

    (@mx760)


    hi
    I found some simple code to add a maintenance mode page which is placed inside functions.php and it’s working but it causes ALL my pages on website to go into maintenance mode. You see, what I had in mind was to keep my website up but when a user clicks a certain link to redirect to this maintenance mode page (it’s still the same page but it overrides my current page as I noticed in URL)

    functions.php I placed:
    =======================
    /***************************************************************************
    * @author: Boutros AbiChedid
    * @date: November 14, 2011
    * @websites: http://bacsoftwareconsulting.com/ ; http://blueoliveonline.com/
    * @description: Function that puts WordPress Website in maintenance mode.
    * @tested on: WordPress version 3.2.1 (but it works on earlier versions.)
    ****************************************************************************/
    function activate_maintenance_mode() {
    //If the current user is NOT an ‘Administrator’ or NOT ‘Super Admin’ then display Maintenance Page.
    if ( !(current_user_can( ‘administrator’ ) || current_user_can( ‘super admin’ ))) {
    //Kill WordPress execution and display HTML maintenance message.
    wp_die(‘<h1>Website Under Maintenance</h1><p>Hi, our Website is currently undergoing scheduled maintenance.
    Please check back very soon.
    Sorry for the inconvenience!</p>’, ‘Maintenance Mode’);
    }
    }
    //Hooks the ‘activate_maintenance_mode’ function on to the ‘get_header’ action.
    add_action(‘get_header’, ‘activate_maintenance_mode’);

    ?>

The topic ‘Maintenance mode troubles’ is closed to new replies.