Last active
March 23, 2019 15:41
-
-
Save techskilled/9e7d0f14cb8cf1c392ce8402127f46cf to your computer and use it in GitHub Desktop.
Wordpress Admin - Enable maintenance mode for non-admins
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @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