Wrong login forwards to wp page

Posted in

When you try to login with the wrong Username or Password you are redirecting to the WP login page.
How to send to a page informing that username or password are wrong?!

6 Responses to Wrong login forwards to wp page

  1. George November 8, 2021 at 6:33 pm #

    Hi Rui,

    You’re welcome and your observation is noted for further investigation and perhaps a new feature.
    Actually that’s exactly what the plugin does, it redirects to a page where you can reset your password and since this page already exists in WordPress Core in the form of wp-login.php then it’s not necessary to create another page for failed logins, using the same elements as the wp-login.php uses to finally create the same result. This is why Affiliates plugin doesn’t use its own page for that purpose.

    Whether you choose to use the default option or you would like to create your own page for failed logins( as your ticket description indicates), it depends on your very own specific use-case and since your use-case is not supported at the moment, this is where hooks come into play. I hope you understand that for a plugin developer it would be almost impossible to try and cover every single case existing out there, so with the help of hooks you can find a workaround that suits.

    Even if you’re not familiar with coding, the explicit details I mentioned are pretty straight forward even for beginners because all you have to do is replace the redirect variable with the URL of your choice ie “http://www.example.com/my_own_page”. Still though if you find yourself in a difficult situation, then you can always ask your site developer for assistance. As your project evolves there will be possibly more cases like this where you will need to fine tune your system accordingly, so a consulting developer is the wisest choice.

    Kind regards,
    George

  2. George November 7, 2021 at 11:23 am #

    Hi Rui,

    You may use something like the following:

    add_action( 'wp_login_failed', 'example_wp_login_failed', 10, 2 );
    function example_wp_login_failed( $username, $error ) {
    $redirect_to = get_home_url();
    wp_redirect( $redirect_to );
    exit;
    }

    It will redirect to the home page if the credentials are not correct and should be placed in functions.php of your active theme, preferably a child theme. You should replace the value of $redirect_to variable with the desired URL of the page you actually want to redirect to.

    When the login attempt is not successful, a visitor should either try to login again or try to recover their credentials, hence the redirect to the wp-admin. On the other hand, the plugin offers the option to redirect after login which can be found in the login.php template and can be overridden if you use your own custom template, but this options is obviously not related to your original request and I’m only mentioning it for the record only.

    Kind regards,
    George

    • Rui Cardoso November 7, 2021 at 6:43 pm #

      Hi, the help is very interesting, but for beginners like me who uses plugins because I don’t know how to use lines of code.
      The best is the plugin itself does the routing to a page of wrong password or credentials. It’s not very professional for a paid plugin to redirect to a WP admin page
      But this is my opinion, hoping that in a next update I will have this situation solved.

  3. George November 5, 2021 at 5:19 pm #

    Hi Rui,

    Sure, let me prepare an example you can use. Once this is ready I’ll follow-up here.

    Kind regards,
    George

  4. Rui Cardoso November 4, 2021 at 6:55 pm #

    I appreciate the attempt to help, but for an insider it is not simple to figure out how to do this.

    The plugin should not have a field that gives this option to redirect pages?

    If you can give a better help, I would be very grateful.

  5. George November 1, 2021 at 10:16 am #

    Hi Rui,

    Welcome back to our support forum.

    I’m assuming that you are referring to the login form found in the Affiliate Dashboard page. This login form is the standard WP form generated by wp_login_form( $args ) function and in order to modify the redirect on failure you can use the action hook:
    do_action( 'wp_login_failed', $username, $error );

    and redirect the failed attempts to the page of your choice.
    Reference:
    https://developer.wordpress.org/reference/hooks/wp_login_failed/

    Kind regards,
    George

We use cookies to optimize your experience on our site and assume you're OK with that if you stay.
OK, hide this message.

Affiliates · Contact · Jobs · Terms & Conditions · Privacy Policy · Documentation · Downloads · Useful Plugins · My Account

Share