Custom wp_login_form don't redirect to wp-login.php
-
Hey all!
I have a custom
wp_login_form()
on a page that if a user successfully logs in gets the page content.I have set my login attempts to 3, before getting locked out.
I have a function that redirects the user to the same page if login fails
add_action( 'wp_login_failed', 'custom_login_failed' ); function custom_login_failed( $username ) { $referrer = wp_get_referer(); if ( $referrer && ! strstr($referrer, 'wp-login') && ! strstr($referrer,'wp-admin') ) { wp_redirect( add_query_arg('login', 'failed', $referrer) ); exit; } }
I am also printing an error message for the user with ` if(isset($_GET[‘login’]) && $_GET[‘login’] == ‘failed’) {
echo'<div id=”login-error” style=”background-color: #FFEBE8;border:1px solid #C00;padding:5px;”>’;
echo’Login failed: You have entered an incorrect Username or password, pease try again.’;
echo'</div>’;
}`Everything works great, however after the 3rd unsuccessful attempt, it redirects to the standard wp-login.php backend with the login lockdown error message. Is there a way to keep the user on the current page and display the login lockdown message there?
- The topic ‘Custom wp_login_form don't redirect to wp-login.php’ is closed to new replies.