Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Adds a Failed Login Attempts action to the Users Connector
<?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