Force Maintenance Mode
Photo Credit

Force Maintenance Mode

Version: 1.1

Forces website into maintenance mode. Disable plugin to re-enable site.

How to Use

Download > Install > Activate. That's it!

Example

Once activated, website will be forced into WordPress "maintenance mode" until deactivated. Edit the text to fit your needs, will accept HTML tags. Be sure to purge all caches (browser & server) and be logged out to view.

Source

This code can be pasted into the functions.php file of your child theme or, download and install the plugin for simple code activation.
/*
Plugin Name: Lightweight Plugins - Force Maintenance Mode
Plugin URI: https://lightweightplugins.com/plugin/force-maintenance-mode
Description: Forces website into maintenance mode. Disable plugin to re-enable site.
Version: 1.1
Author: WP Maintenance Experts
Author URI: https://wpmaintenanceexperts.com/
License: GPLv2 or later
*/

function lightweight_plugins_force_maintenance_mode() {
  if (!current_user_can('edit_themes') || !is_user_logged_in()) {
  wp_die('Website Unavailable');
  }
  }
  add_action('get_header', 'lightweight_plugins_force_maintenance_mode');

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *