• Resolved rechnerhaus

    (@rechnerhaus)


    Since version 3.2.18 the frontend login with wordfence 2FA enabled does not work anymore. Invalid username and password instead of redirecting to wp-login.php to enter 2FA code like it used to work before.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Omar ElHawary

    (@omarelhawary)

    Hi @rechnerhaus,

    Thanks for reaching out Members Support Team!

    I was able to replice the issue from my end. I addressed the bug to dev team so they can fix the issue.

    Regards,

    Thread Starter rechnerhaus

    (@rechnerhaus)

    Thank you

    Plugin Support Omar ElHawary

    (@omarelhawary)

    Hi @rechnerhaus,

    Please copy/paste below PHP snippet to theme functions.php or any code snippet plugin and let me know if it helps:

    // Add a 2FA code field to the Members login form shortcode and combine it with the password on submit.
    add_filter('login_form_bottom', function($content) {
    if ( !is_admin() && !defined('DOING_AJAX') ) {
    ob_start();
    ?>
    <div id="members-2fa-wrapper" style="margin-top: 16px;">
    <label for="members-2fa-code">2FA Code</label>
    <input type="text" name="members_2fa_code" id="members-2fa-code" class="input" autocomplete="one-time-code" />
    <small style="display:block;margin-top:4px;color:#666;">
    If you have 2FA enabled, enter your code. Otherwise, leave this field blank.
    </small>
    </div>
    <script>
    document.addEventListener('DOMContentLoaded', function() {
    var form = document.getElementById('loginform');
    var twoFA = document.getElementById('members-2fa-wrapper');
    var pass = form ? form.querySelector('input[type="password"]') : null;
    if(form && twoFA && pass) {
    // Move the 2FA field right after the password field
    pass.parentNode.insertBefore(twoFA, pass.nextSibling);
    // Combine password and 2FA code on submit
    form.addEventListener('submit', function(e) {
    var code = form.querySelector('input[name="members_2fa_code"]');
    if(pass && code && code.value) {
    pass.value = pass.value + code.value;
    }
    });
    }
    });
    </script>
    <?php
    $content .= ob_get_clean();
    }
    return $content;
    });

    // Remove the Members plugin's default error message
    remove_filter('login_form_bottom', 'members_login_form_bottom');

    // Add a custom error message for the Members login form
    add_filter('login_form_bottom', function($output) {
    $output .= '<input type="hidden" name="members_redirect_to" value="1" />';
    if ( isset( $_GET['login'] ) && $_GET['login'] == 'failed' ) {
    $output .= '<p class="members-login-notice members-login-error">' . esc_html( 'Invalid username, password, or 2FA code.', 'members' ) . '</p>';
    }
    return $output;
    }, 20);

    Looking forward to hearing back from you.

    Regards,

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘wordfence 2FA issue’ is closed to new replies.