Limit Login Attempts
Limits the number of login attempts to prevent brute force attacks
PHP
function limit_login_attempts($user, $username, $password) {
if (get_transient('attempted_login')) {
$wait_seconds = 300;
return new WP_Error('too_many_attempts', sprintf(__('You can try again in %d seconds.'), $wait_seconds));
}
return $user;
}
add_filter('authenticate', 'limit_login_attempts', 30, 3);
Snippet Feedback
Did this snippet work for you? Do you have any questions about this snippet? Leave some feedback below.
SHARED BY
3 Views