Last active
August 29, 2015 14:01
-
-
Save fjarrett/3fea31fd015bbcd7c92c to your computer and use it in GitHub Desktop.
Adds a Failed Login Attempts action to the Users Connector
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class WP_Stream_Connector_Failed_Login_Attempts extends WP_Stream_Connector_Users { | |
/** | |
* Actions registered for this connector | |
* | |
* @var array | |
*/ | |
public static $actions = array( | |
'wp_login_failed', | |
); | |
/** | |
* Return translated action term labels | |
* | |
* @return array Action terms label translation | |
*/ | |
public static function get_action_labels() { | |
return array( | |
'failed_login' => __( 'Failed Login', 'stream-connector-failed-login-attempts' ), | |
); | |
} | |
/** | |
* Track failed login attempts | |
* @param arary $errors | |
* @param string $redirect_to | |
* @return array | |
*/ | |
public static function callback_wp_login_failed( $username ) { | |
$user = get_user_by( 'login', $username ); | |
self::log( | |
__( 'Invalid login attempt for %s', 'stream-connector-failed-login-attempts' ), | |
compact( 'username' ), | |
$user ? $user->ID : 0, | |
array( 'sessions' => 'failed_login' ), | |
$user ? $user->ID : 0 | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment