Skip to content

Instantly share code, notes, and snippets.

@salcode
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save salcode/19c965332edb9afb9cf3 to your computer and use it in GitHub Desktop.
Save salcode/19c965332edb9afb9cf3 to your computer and use it in GitHub Desktop.
Code to add to the beginning wp-config.php that causes WordPress to shutdown without ever connecting to the database if someone tries to login with the username "admin"
<?php
// ** Reject Bad Username ** //
/** As described on http://salferrarello.com/wordpress-bad-login-attempts/ **/
$bad_user_names = array( 'admin' );
if (
isset( $_POST['log'] )
&& in_array( strtolower( $_POST['log'] ), $bad_user_names )
&& false !== stripos( $_SERVER['REQUEST_URI'], 'wp-login.php' )
) {
die();
}
// ** MySQL settings ** //
/** The name of the database for WordPress */
define('DB_NAME', 'example');
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment