Skip to content

Instantly share code, notes, and snippets.

@georgestephanis
Last active February 4, 2026 17:59
Show Gist options
  • Select an option

  • Save georgestephanis/7877ba8a43178b306d0db0d2e8d6547a to your computer and use it in GitHub Desktop.

Select an option

Save georgestephanis/7877ba8a43178b306d0db0d2e8d6547a to your computer and use it in GitHub Desktop.
Drop this file into `wp-content/mu-plugins/` and it will disable login and authentications. Why would you want this? Maybe you need to make an editorial freeze before migrating a site from one host to another, and don't want to risk admins writing content that would get lost in the migration.
<?php
// Usage: Drop this file into `wp-content/mu-plugins/` and it will disable logins and authentication.
namespace WPFreeze;
// In addition, the salts should be temporarily rotated in wp-config.php to invalidate existing sessions.
define( 'WP_FREEZE_MESSAGE', 'This site is currently frozen for maintenance. Please check back later.' );
/**
* Prevent logins.
*/
add_filter( 'wp_authenticate_user', function() {
return new WP_Error( 'authentication_failed', WP_FREEZE_MESSAGE );
} );
/**
* Display freeze message on login page.
*/
add_filter( 'login_message', function( $message ) {
return '<p class="message">' . WP_FREEZE_MESSAGE . '</p>' . $message;
} );
/**
* Hide login form.
*/
add_action( 'login_enqueue_scripts', function() {
wp_add_inline_style(
'login',
' body.login #loginform,
body.login #nav,
body.login .language-switcher {
display:none;
}'
);
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment