wrong credentials goes to WP login

How do I get it so when an affiliate puts in the wrong User ID or Password they do not get redirected to the WP login?

One Response to wrong credentials goes to WP login

  1. George April 28, 2017 at 11:24 am #

    Hi Carolyn,

    This happens mainly because in the affiliates login form there isn’t a reset password link, so in case the affiliate has indeed lost/forgot their password, they get the chance to reset it. Still though even if they login successfully through the wp-login form, they will be redirected to their affiliates area page.

    If though you still want to keep affiliates to the same page after a failed login, you should put this snippet to your functions.php file of your active theme, preferably a child theme.

    add_action( 'wp_login_failed', 'gt_login_fail' );
    function gt_login_fail( $username ) {
    $referrer = $_SERVER['HTTP_REFERER'];

    if ( !empty( $referrer ) && !strstr( $referrer, 'wp-login') && !strstr( $referrer, 'wp-admin') ) {
    wp_redirect( $referrer . '?login=failed' );
    exit;
    }
    }

    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