Help Desk

Failed Login redirect

  • Posts: 130 Topics: 41
    | Permalink

    Using the default login page (/events/courses/list) if the login fails the user gets sent to the default ugly unbranded WP login page. First, this seems wrong. Isn’t there error trapping for this?

    I solved it with a function I found (see below) and this works fine, but I wanted to check since it doesn’t seem like it should be necessary. Is there a better way to do this? Or error trapping for this I can modify or that isn’t working properly?

    My function:

    (add_action( 'wp_login_failed', 'thai_login_fail' );  
    function thai_login_fail( $username ) {
         $referrer = $_SERVER['HTTP_REFERER'];  
         if ( !empty($referrer) && !strstr($referrer,'wp-login') && !strstr($referrer,'wp-admin') ) {
              wp_redirect('/events/courses/list' . '/?login=failed' ); 
              exit;
         }
    }
    

    Thanks!

    Posts: 4171
    | Permalink

    Hey Mad Dog,

    Thanks for reaching out to us!

    This is an interesting point and does make sense. Currently, the code snippet is needed to have the failed login redirect back to the community events login. I’ve created a new internal ticket for this and you’ll be notified if/when our team pushes forward with changing this behavior.

    Thanks!

    Posts: 130 Topics: 41
    | Permalink

    Seems it should be pretty simple to put error checking on the page so it stays there but an error message appears. In fact, I may need to add something to the page to display an error message (by way of the “failed login” URL parameter)so the user knows something happened and doesn’t just wonder what’s going on.

    Keep me posted.

    THANKS

    Posts: 130 Topics: 41
    | Permalink

    Two questions:

    1. Is the only way to add an error message to the login page by using a function?

    2. When I do, using login_message doesn’t work.

    I can use login_form_bottom to check if the URL parameter login=failed and it works and places a message jusst above the login form, but is there a better way to do this?

    // Add LOGIN ERROR  message  to login page
    add_action( 'login_form_bottom', 'login_error_message' );
    function login_error_message() {
    	if (isset($_GET['login']) && $_GET['login'] == 'failed') {
    		echo "<div class='login_error'>Login and Password don't match.<br />Please check them and try again.</div><br /><br />";
    	}
    }

    Thanks!

    Posts: 4171
    | Permalink

    Hey Mad Dog,

    The login form for the community events plugin utilizes the “wp_login_form” function from WordPress. The way you have the error message added would work. Also, there are other options out there such as this one from the WordPress.org forums.

    Let me know if this helps.

    Thanks!

    Posts: 130 Topics: 41
    | Permalink

    It works as I have it so I’ll leave it. Let me know if they redo the whole login page error trapping so it works more like we both think it should.

    Thanks!

    Posts: 4171
    | Permalink

    Hey Mad Dog,

    No problem. This thread has been added to our internal ticket for tracking this. You’ll be notified here as we make progress.

    I’ll go ahead and close this thread for now. If you have any further questions, please don’t hesitate to open a new thread.

    Thanks!

    Posts: 1675
    | Permalink

    Hi there!

    Just wanted to share with you that a new release of our plugins is out which includes a fix for this issue.

    Find out more about it → https://theeventscalendar.com/maintenance-release-for-the-week-of-15-july-2019/

    We apologize for the delay and appreciate your patience while we worked on this.

    As always, we suggest to setup a dev/staging site so you can make all plugin updates without disrupting the live site.

    Please update the plugins and let us know if the fix works for you.

    Cheers,
    Jeremy