Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Disable WordPress User Login During Maintenance
// 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
You can’t perform that action at this time.