Custom login form code causing errors
-
Hi!
One of our prior developers used this code in our functions file for our custom login form redirects
// Redirect user in case failed auth from login page add_action( 'wp_login_failed', 'my_front_end_login_fail' ); // hook failed login function my_front_end_login_fail( $username ) { $referrer = $_SERVER['HTTP_REFERER']; // where did the post submission come from? // if there’s a valid referrer, and it’s not the default log-in screen if ( !empty($referrer) && !strstr($referrer,'wp-login') && !strstr($referrer,'wp-admin') ) { if ( !strstr($referrer,'?login=failed') ) { // make sure we don’t append twice wp_redirect( $referrer . '?login=failed' ); // let’s append some information (login=failed) to the URL for the theme to use } else { wp_redirect( $referrer ); } exit; } } global $wp_version; if ( version_compare( $wp_version, '3.0', '>=' ) ) : add_theme_support( 'automatic-feed-links' ); else : automatic_feed_links(); endif; // Redirect user in case failed auth from login page add_action( 'authenticate', 'my_custom_function'); function my_custom_function(){ $referrer = $_SERVER['HTTP_REFERER']; if ( strstr($referrer,'login') && $user==null ) { if ( !strstr($referrer,'?login=nodata') ) { wp_redirect( $referrer . '?login=nodata' ); } else { wp_redirect( $referrer ); } } }Problem is the function titled my_custom_function is causing users who click on the request new password link to hit an error page after submitting their email address. It says too many redirects and the address it’s going too is http://our-website-here.com/wp-login.php?action=lostpassword?login=nodata
When I remove that code it’s successful and redirects to here http://our-website-here.com/wp-login.php?checkemail=confirm
Any ideas how I could keep whatever necessary functionality is there but change the coding so we don’t get the errors?
Thanks
The topic ‘Custom login form code causing errors’ is closed to new replies.