Created
August 13, 2020 06:00
-
-
Save yanknudtskov/644c4c0740aafe4fa83b6c64a7116536 to your computer and use it in GitHub Desktop.
Add query string if failed login with Elementor Pro Login Form
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'wp_login_failed', 'yanco_elementor_form_login_fail' ); | |
function yanco_elementor_form_login_fail( $username ) { | |
// where did the post submission come from? | |
$referrer = $_SERVER['HTTP_REFERER']; | |
// 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') ) { | |
//redirect back to the referrer page, appending the login=failed parameter | |
$redirect_to = add_query_arg( array( | |
'login' => 'failed', | |
), $referrer ); | |
wp_redirect( $redirect_to ); | |
exit; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment