Skip to content

Instantly share code, notes, and snippets.

@jllodra
Created November 12, 2012 19:44
Show Gist options
  • Save jllodra/4061455 to your computer and use it in GitHub Desktop.
Save jllodra/4061455 to your computer and use it in GitHub Desktop.
Wordpress "custom redirect when login fails" plug-in
<?php
/*/
Plugin Name: Fail login redirect
Plugin URI: http://herotyc.untergrund.net
Description: Redirect to custom page when login fails
Version: 1.0
Author: Josep Llodra
Author URI: http://herotyc.untergrund.net
/*/
add_filter('login_redirect', '_catch_login_error', 10, 3);
function _catch_login_error($redir1, $redir2, $wperr_user)
{
if(!is_wp_error($wperr_user) || !$wperr_user->get_error_code()) return $redir1;
switch($wperr_user->get_error_code())
{
case 'incorrect_password':
case 'empty_password':
case 'invalid_username':
default:
wp_redirect('/wordpress/login-failed/'); // modify this as you wish
}
return $redir1;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment