How 2FA works
Two-factor authentication (2FA) adds a second step to the login. After a user enters the right username and password, Shield asks for a one-time code. A stolen or guessed password is no longer enough to get in.
The basics#
- When 2FA is on, every user in the roles you choose is asked for a code on every password login. By default that is all roles, and roles added later are covered too.
- Email codes are always on. They are the baseline, so no one can skip the second step.
- Users can add a stronger method: an authenticator app or a passkey.
- Users can’t turn 2FA off for themselves. An administrator can reset another user’s methods, for example after a lost phone. That user falls back to email codes.
The login flow#
- The user enters their username and password.
- If the password is right and the user needs a second step, Shield ends the session WordPress just started. The user is not logged in yet.
- Shield sends them to a challenge page.
- The user enters the code, and Shield completes the login and sends them to where they were headed.
The user has 10 minutes to finish the challenge. After that they see “Your two-factor session timed out (10 minutes)” and enter their password again.
Which method a user gets#
| The user has… | What happens on login |
|---|---|
| Nothing added | A 6-digit code is emailed to them automatically. |
| An authenticator app or passkey | They use that method first. The code is not emailed automatically, but “Email me a code” is available on the challenge page. |
Backup codes work as a fallback for any user who has them.
If more than one stronger method exists, Shield uses them in this order: passkey, then authenticator app, then email.
Email codes#
- The code has 6 digits.
- It is valid for 10 minutes.
- A new code can be requested once every 60 seconds.
- A code allows 5 wrong attempts, then it is discarded.
- If the email can’t be sent, the challenge page says so and offers “Email me a code” to try again, or a backup code.
The email uses your sender name and design. See “Email branding” below.
Turn on 2FA#
- Go to Settings → Login Shield and open the 2FA tab.
- Turn on Enable 2FA.
- Under Apply to roles, tick the roles that must use 2FA. Every role is ticked by default.
- Under Allowed methods, choose which stronger methods users can add. Email code is always on and can’t be unticked.
- Click Save 2FA settings.
Passkey as a 2FA method also needs Passkeys to be turned on in the Passwordless tab.
Users in a role you didn’t tick sign in with just a password, unless they add an authenticator app or passkey themselves. Then they are challenged too.

Check your own status#
When 2FA is on, a banner at the top of the 2FA tab tells you how your own account signs in:
- If you’ve added a stronger method, it names it.
- If you only use email codes, it warns: “If email delivery fails you’d be locked out — add an authenticator app.”
- If your role isn’t selected, it says you sign in with just your password.
Add an authenticator app before you rely on email codes. See “Set up an authenticator app”.

The status overview#
The bottom of the tab lists users who have added an authenticator app or passkey, with their role and how many backup codes they have left. The count turns red at two or fewer. Users who only use email codes don’t appear, because email is the baseline for everyone.

2FA and the other protections#
- Wrong codes count toward lockout. After five wrong codes, the IP is locked out for 15 minutes and the event is logged.
- A limit also applies per challenge. After five wrong codes on one challenge, it is cancelled and the user must enter their password again, even if they change IP.
- Passkey sign-in already counts as two factors. A user who signs in with a passkey is not asked again, when “passkey satisfies 2FA” is on.
- Magic links: after a magic link, a user who has added an authenticator app or passkey is still asked for that second step. A user who only has email codes is not asked again, because the link already proved they can read that inbox.
- WooCommerce: if the login came from My Account, the challenge appears there in your theme’s styling.
- MainWP: when you open a site’s admin from your MainWP Dashboard, the challenge is skipped. Normal logins on that site are still challenged.
Email branding#
Shield’s emails (the 2FA code, the magic link and the signup confirmation) use one template that you can brand. Go to Settings → Login Shield, open the Settings tab and find Email branding.
- Sender name and Sender email. Use an address on your own domain, or leave it empty for the WordPress default.
- Logo. PNG or JPG, up to 180 px wide. Without a logo, your site name is shown.
- Colours. An accent colour for buttons, links and the code box, and a header colour.
- Footer text.
- Credit. An optional “Protected by Nahnu Login Shield” line. It is off by default, so emails carry no plugin branding.
- Email content. Edit the subject, heading and message of the two-factor code and magic link emails. Clear a field to return to the built-in wording. The signup confirmation email is edited on the Access tab, under Signup email verification.
| Placeholders | |
|---|---|
| Two-factor code | {site_name} {user_name} {code} {minutes} {ip} |
| Magic login link | {site_name} {user_name} {link} {minutes} {ip} |
The code box and the sign-in and confirmation buttons are always shown, even if you remove the placeholder from the text.
Use Preview to see the saved version, and Send test to your address to receive the two-factor email with the sample code 123456.


Locked out of 2FA#
If email isn’t arriving and you have no authenticator app or backup code, add this line to wp-config.php, above the “That’s all, stop editing” line:
define( 'NAHNLS_DISABLE_2FA', true ); This switches 2FA off for everyone, so you can sign in with just your password. A notice shows on the settings page while it is set. Fix email delivery (an SMTP plugin usually does it), add an authenticator app, and then remove the line.
NAHNLS_BYPASS_IP does not bypass 2FA. It only exempts addresses from lockouts, the blocklist, geo-blocking and the early-block rate limit.
Before you turn it on#
Because email codes are the baseline, make sure your site can send email. Send yourself a test email from the Email branding section first. Then add an authenticator app to your own account before you enable 2FA for everyone.
What 2FA protects against, and what it doesn’t#
2FA protects against stolen, reused or guessed passwords. It doesn’t protect a session that is already logged in. Use the session security options for that.
Was this helpful?
Thanks for your feedback!
✓ Feedback received. Thank you!