Skip to content

Instantly share code, notes, and snippets.

@techskilled
Last active March 23, 2019 15:41
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 techskilled/9e7d0f14cb8cf1c392ce8402127f46cf to your computer and use it in GitHub Desktop.
Save techskilled/9e7d0f14cb8cf1c392ce8402127f46cf to your computer and use it in GitHub Desktop.
Wordpress Admin - Enable maintenance mode for non-admins
/**
* @snippet Wordpress Admin - Enable maintenance mode for non-admins
* @code https://techskilled.co.uk/snippets/admin-enable-maintenance-mode-for-non-admins-2
* @author https://techskilled.co.uk
*/
function wpts_maintenance_mode(){
if(!current_user_can(‘edit_themes’) || !is_user_logged_in()){
wp_die(‘Under Maintenance, please come back soon.’, ‘Under Maintenance – please come back soon.’, array(‘response’ => ‘503’));
}
}
add_action(‘get_header’, ‘wpts_maintenance_mode’);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment