WordPress.org

Ready to get started?Download WordPress

Forums

Sidebar Login
How to not redirect to wp-login.php if login fails? (5 posts)

  1. takien
    Member
    Posted 2 years ago #

    If user failed to login, it should not redirected to wp-login.php
    how to dot that?
    thanks.

    http://wordpress.org/extend/plugins/sidebar-login/

  2. syd16
    Member
    Posted 1 year ago #

    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. ]

  3. Hasel
    Member
    Posted 1 year ago #

    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...

  4. madkad
    Member
    Posted 1 year ago #

  5. johnpaul_86
    Member
    Posted 1 year ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.