Viewing 4 replies - 1 through 4 (of 4 total)
  • Yes I’d like to know this as well. Is it possible to have a message or something as WP-Members does such as “Login has failed. Please try again” rather than redirecting to a WordPress page (wp-login.php)?

    [ Please do not bump, that’s not permitted here. ]

    Hasel

    (@hasel)

    I have exactly the same problem. If either of you above resolved it somehow, I would love to know, or if there is anybody else out there…

    add this hook in your functions.php

    /*-------------------------------------------------------------------------------------*/
    /* Login Hooks and Filters
    /*-------------------------------------------------------------------------------------*/
    if( ! function_exists( 'custom_login_fail' ) ) {
        function custom_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' ); // append some information (login=failed) to the URL for the theme to use
                } else {
                    wp_redirect( $referrer );
                }
                exit;
            }
        }
    }
    add_action( 'wp_login_failed', 'custom_login_fail' ); // hook failed login
    if( ! function_exists( 'custom_login_empty' ) ) {
        function custom_login_empty(){
            $referrer = $_SERVER['HTTP_REFERER'];
            if ( strstr($referrer,get_home_url()) && $user==null ) { // mylogin is the name of the loginpage.
                if ( !strstr($referrer,'?login=empty') ) { // prevent appending twice
                    wp_redirect( $referrer . '?login=empty' );
                } else {
                    wp_redirect( $referrer );
                }
            }
        }
    }
    add_action( 'authenticate', 'custom_login_empty');

    i guess this will help you..it solved my problem.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: Sidebar Login] How to not redirect to wp-login.php if login fails?’ is closed to new replies.