Last active
January 22, 2020 10:08
-
-
Save edlefebvre/87638c90a840e6bbd6d8c9e6a1b11676 to your computer and use it in GitHub Desktop.
WP Maintenance mu-plugin - redirect to login page
This file contains hidden or 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
<?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