WordPress.org

Ready to get started?Download WordPress

Forums

Sidebar Login Widget
Login fail redirect (6 posts)

  1. lauriekane@yahoo.com
    Member
    Posted 11 months ago #

    Hi, How can I redirect to login.php when login fails?

    https://wordpress.org/plugins/tt-sidebar-login-widget/

  2. bridieamelia
    Member
    Posted 11 months ago #

    Yes I am getting an error with login fail also. The URL is:

    http://www.mydomain.com/?login=failed&errcode=incorrect_password

    But it goes back to the homepage.

  3. Rashed Latif
    Member
    Plugin Author

    Posted 11 months ago #

    This plugin is developed in that way. When login attempt is failed it will redirect to home page. Because sidebar login widget will be on the home page sidebar in most of the cases so user can try to login again.

    But if you want that after the login failure it will be redirected to worpress login screen then replace the following code

    wp_redirect(home_url() . '/?login=failed&errcode='.$current_error );

    with

    wp_redirect( $referrer . '/wp-login.php' );

    This line is in function called "handle_login_failure"

    Hope that will help.

  4. bridieamelia
    Member
    Posted 11 months ago #

    Thanks for the quick reply!

    In my case at least, there is no sidebar on the homepage. The code you've suggested (thanks!) adds the /wp-login.php to whatever the current URL is, so this doesn't work if the login sidebar is on another page.

    I would suggest the following instead:

    wp_redirect( home_url() . '/wp-login.php' );

    Bridie

  5. Rashed Latif
    Member
    Plugin Author

    Posted 11 months ago #

    Yes thats definitely a solution but i just figured out both our solution may end up with redirection loop problem for some hosts.

    The best way to redirect to wp-login page is disable/remove the following portion of code and let wordpress handle it.

    add_action('wp_login_failed', 'handle_login_failure');
    /*
     * This method will handle the login failure process.
     */
    function handle_login_failure($username){
    	// check what page the login attempt is coming from
      	global $current_error;
    	$referrer = $_SERVER['HTTP_REFERER'];
    	if ( !empty($referrer) && !strstr($referrer,'wp-login') && !strstr($referrer,'wp-admin') ) {
    		wp_redirect(home_url() . '/?login=failed&errcode='.$current_error );
    		exit;
    	}
    }
  6. amadreamer
    Member
    Posted 1 month ago #

    Hi,

    I would like to be able to add link that goes directly to WP Login page.
    Actually when it redirect to the homepage where there is the Widget.

    The problem is that widget is in the bottom of the page, so not easy to find the right way for users to log in or register.

    Is there's a way to make the link go straight to the WP login page or to force it to go there ?

    Thanks.

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.