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?


Comments

One response to “wrong credentials goes to WP login”

  1. 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

Share