Skip to content

Instantly share code, notes, and snippets.

@dexit
Forked from yanknudtskov/functions.php
Created April 11, 2024 09:09
Show Gist options
  • Save dexit/e367cdbda7e054e898166de47898a7a6 to your computer and use it in GitHub Desktop.
Save dexit/e367cdbda7e054e898166de47898a7a6 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