Created
August 17, 2013 16:41
-
-
Save TechRemarker/6257728 to your computer and use it in GitHub Desktop.
Disable WordPress User Login During Maintenance
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
// MAINTAINANCE MODE | |
//Disables login for 'editor' and custom 'revisor' user roles. | |
function site_maintenance() { | |
if ( current_user_can('editor') || current_user_can('revisor') ) { | |
$logout_url = wp_login_url().'?mode=maintainance'; | |
wp_logout(); | |
wp_redirect( $logout_url, 302 ); | |
} | |
} | |
add_action('get_header', 'site_maintenance'); | |
// CUSTOM LOGIN MESSAGES | |
function my_login_message() { | |
if( $_GET['mode'] == 'maintainance' ){ | |
$message = '<p class="message"><b>Site undergoing maintainance.</b></p>'; | |
return $message; | |
} | |
} | |
add_filter('login_message', 'my_login_message'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment