Skip to content

Instantly share code, notes, and snippets.

@fjarrett
Last active August 29, 2015 14:01
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 fjarrett/3fea31fd015bbcd7c92c to your computer and use it in GitHub Desktop.
Save fjarrett/3fea31fd015bbcd7c92c to your computer and use it in GitHub Desktop.
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