Today quick script to put your wordpress site in maintenance mode.
Just paste the code that in functions.php and only logged in user will see the front end of the site:
<?php
/***************************************************************************
* @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.<br /><strong>Sorry for the inconvenience!</strong></p>', 'Maintenance Mode');
}
}
//Hooks the 'activate_maintenance_mode' function on to the 'get_header' action.
add_action('get_header', 'activate_maintenance_mode');
?>
Thanks to http://bacsoftwareconsulting.com
Leave a Reply