Skip to content

Instantly share code, notes, and snippets.

@yanknudtskov
Created August 13, 2020 06:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save yanknudtskov/644c4c0740aafe4fa83b6c64a7116536 to your computer and use it in GitHub Desktop.
Save yanknudtskov/644c4c0740aafe4fa83b6c64a7116536 to your computer and use it in GitHub Desktop.
Add query string if failed login with Elementor Pro Login Form
<?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