这里的首要答案是糟糕透顶的PHP代码,完全崩溃了。这是一个很好的版本。我的声望太低,无法对最初的答案发表评论。
此代码可以放在wp-config.php 在紧要关头。
function wpse208677_authenticate($user,$username,$pass) {
remove_filter(\'authenticate\',\'wp_authenticate_username_password\',20,3);
return null;
// if you want to whitelist your ip check for it and return $user
}
add_filter(\'authenticate\',\'wpse208677_authenticate\', 1,3)
另一个选项是阻止访问登录/注册页面。这甚至可以在WordPress的隐藏登录url后面工作。此代码可以放在
wp-config.php (打开后
<?php.
if ( in_array( $_SERVER[\'PHP_SELF\'], array( \'/wp-login.php\', \'/wp-register.php\' ) ) ){
die(\'Site in maintenance mode.\');
}