Skip to content

Instantly share code, notes, and snippets.

@edlefebvre
Last active January 22, 2020 10:08
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 edlefebvre/87638c90a840e6bbd6d8c9e6a1b11676 to your computer and use it in GitHub Desktop.
Save edlefebvre/87638c90a840e6bbd6d8c9e6a1b11676 to your computer and use it in GitHub Desktop.
WP Maintenance mu-plugin - redirect to login page
<?php
// Exit if accessed directly
if ( !defined('ABSPATH') ) exit;
/**
* Plugin Name: Maintenance mode
* Description: maintenance mode.
* Author: EDL
* Author URI:
* Version: 1.1
*/
// Redirect to login page if user is not logged in
function activate_maintenance_mode() {
auth_redirect();
}
/* Hooks the 'activate_maintenance_mode' function on to the 'template_redirect' action. */
//if( WP_ENV == "staging" || WP_ENV == "production" ) {
if( WP_ENV == "staging" ) {
add_action('template_redirect', 'activate_maintenance_mode');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment