/** * The following will restrict login to a * specific IP address. * * Change "111.111.111.111" to the actual IP. */ add_action( 'authenticate', function( $user, $username, $password ) { $ip = ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) ? $_SERVER['HTTP_CLIENT_IP'] : $_SERVER['REMOTE_ADDR']; if ( '111.111.111.111' != $ip ) { $user = new WP_Error( 'authentication_failed', __( '<strong>ERROR</strong>: You are not allowed to log in to that account from this IP.' ) ); } return $user; }, 100, 3 );
Restrict WordPress login by IP address
This post brought to you by RocketGeek, ButlerBlog, and the following: