Maintenance mode for the admin only

Adding this snippet to the functions.php of your wordpress theme will put only your wordpress admin section into maintenance mode. I have had a few projects that have required me to do this for a number of reasons so I had put this little snippet together. Don’t forget to change ADMIN_NAME to the username for your account.

 

 

function admin_maintenace_mode() {
global $current_user;
get_currentuserinfo();
if($current_user->user_login != 'ADMIN_NAME') { ?>
<style> .updated{margin:30px !important;} </style><?
wp_die('<div id="message" class="updated"><p><b>Maintenance mode:</b> We are currently making updates. Everything will be online shortly.</p></div>');
}
}
add_action('admin_head', 'admin_maintenace_mode');

Be Sociable, Share!

Leave a comment