Sidebar Login Widget
Login fail redirect (6 posts)

  1. lauriekane@yahoo.com
    Posted 1 year ago #

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


  2. bridieamelia
    Posted 1 year ago #

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


    But it goes back to the homepage.

  3. Rashed Latif
    Plugin Author

    Posted 1 year 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 );


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

    This line is in function called "handle_login_failure"

    Hope that will help.

  4. bridieamelia
    Posted 1 year 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' );


  5. Rashed Latif
    Plugin Author

    Posted 1 year 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 );
  6. amadreamer
    Posted 8 months ago #


    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 ?


Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Sidebar Login Widget
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.