Display Simple Maintenance Mode Message to Non-Admins

Print Page

Here’s a snippet to display a simple maintenance mode message to all non-admin visitors of your WordPress blog, while you carry on your tasks in the back-end.

function wp_maintenance_mode() {
	if ( !is_user_logged_in() || !current_user_can( 'manage_options' ) ) {
	wp_die('Site is undergoing maintenance at the moment, please come back after some time.');
	}
}
add_action('get_header', 'wp_maintenance_mode');

Paste and save the code in your default theme’s functions.php. After completing your tasks, simply delete the code.