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.

Code Snippet:

function admin_maintenace_mode() {
global $current_user;
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');

Comments  Leave a Reply

  1. wp-securehosting.com September 18, 2017 at 6:40 pm

    Thanks Kevin. I’m in a similar situation as squarecandy. I don’t want people modifying their site while I’m migrating them to my web-hosting company.

  2. Cool – thanks.
    This worked for me – I’m transitioning between servers and I didn’t want users editing their sites between when I started to copy everything over and when I made the switch to the new server.

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!