Google

Redirect after failed login attempt in WordPress

Written on:December 16, 2011
Comments
Add One

Here’s another piece of php code for redirecting to any page after a login error in wordpress.

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('/login-failed'); // modify this as you wish
	}

	return $redir1;
}

Leave a Comment

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>