Skip to content

Instantly share code, notes, and snippets.

@whatadewitt
Last active December 17, 2015 05:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whatadewitt/5559821 to your computer and use it in GitHub Desktop.
Save whatadewitt/5559821 to your computer and use it in GitHub Desktop.
WP Maintenance Mode
// Temp Maintenance - with http response 503 (Service Temporarily Unavailable)
// This will only block users who are NOT an administrator from viewing the website.
function wp_maintenance_mode(){
if(!current_user_can('edit_themes') || !is_user_logged_in()){
wp_die('Maintenance, please come back soon.', 'Maintenance - please come back soon.', array('response' => '503'));
}
}
add_action('get_header', 'wp_maintenance_mode');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment