Skip to main content

How to Set Up Two-Factor Authentication for WordPress Admin Logins

  • By Md Sayfur Rahman
  • 6 min read
How to Set Up Two-Factor Authentication for WordPress Admin Logins

Most hacked WordPress sites are not broken into through complex attacks. Very often, the attacker simply logs in with a real username and password that was guessed, reused from another website, or stolen in a data leak. Two-factor authentication, often called 2FA, stops this kind of attack because a password alone is no longer enough to get in.

This guide explains why 2FA matters for WordPress, what the research says about how well it works, which method to choose, how to set it up, and how to avoid the most common problem people report, which is locking themselves out.

Why Passwords Alone Are Not Enough

Every WordPress site has a login page at a known address, so bots can try to log in to millions of sites without any human effort. Some bots try common passwords. Others use lists of email addresses and passwords taken from data leaks on other websites, because many people use the same password in more than one place.

A strong password helps, but it does not protect you if it is stolen. Passwords can be captured by fake login pages, by malware on a computer, or in a leak from another service you used. Once an attacker has the password, nothing else stops them unless there is a second step.

With 2FA, a user must enter their password and then prove they have something else, usually a phone with an authenticator app. The app shows a six-digit code that changes every 30 seconds. An attacker who only has the password cannot complete the login.

What the Data Says About Two-Factor Authentication

The amount of login attacks on WordPress sites is very large. In the first six months of 2021 alone, the Wordfence firewall blocked more than 86 billion password attack attempts against the WordPress sites it protects. Most of these were automated bots trying many username and password combinations.

Google studied how well different second steps protect accounts against three types of attacks. Automated bots are mass attacks run by software. Bulk phishing uses fake emails sent to many people. Targeted attacks are aimed at one specific person or business.

Second step usedAutomated bots blockedBulk phishing blockedTargeted attacks blocked
Code sent by SMS100%96%76%
Prompt on a phone app100%99%90%
Physical security key100%100%100%

The most important number for most WordPress sites is the first column. Almost all login attacks on WordPress are automated, and any form of 2FA stopped all of them in Google's research. The other columns show that stronger methods give better protection against phishing and attacks aimed at you personally.

Which 2FA Method Should You Use?

WordPress does not include 2FA by default, so you add it with a plugin. Most plugins offer several methods, and they are not all equal. The list below goes from the weakest to the strongest option.

  • Email codes. A code is sent to your email address. This is easy to use, but if your email account is hacked, the attacker gets the code too.
  • SMS codes. A code is sent by text message. This is better than no 2FA, but text messages can be redirected if an attacker takes over your phone number.
  • Authenticator apps. Apps such as Google Authenticator, Microsoft Authenticator, Authy or a password manager create the codes on your phone. This is the best choice for most site owners.
  • Security keys and passkeys. A physical key or a passkey on your device confirms the login. This is the strongest option and works well for administrators of important sites.

For most business websites, an authenticator app is the right balance of security and ease of use. If you manage many client sites or an online store with valuable customer data, consider security keys for the main administrator accounts.

How to Set Up 2FA in WordPress

Several well-known plugins add 2FA to WordPress, including Wordfence, Two Factor, WP 2FA and miniOrange. Many security plugins also include 2FA as one of their features, so check what you already use before you add a new plugin. The basic setup is similar in all of them.

  • Install and activate your chosen 2FA plugin.
  • Open your user profile or the plugin's settings page and start the 2FA setup.
  • Scan the QR code with your authenticator app.
  • Enter the six-digit code from the app to confirm that it works.
  • Download or print the backup codes and keep them in a safe place.
  • In the plugin settings, make 2FA required for all users who can manage or publish content.

The last step is easy to forget. Many plugins let each user decide whether to use 2FA, and then most users never turn it on. Make it required for administrators, editors and, on WooCommerce sites, shop managers, because these accounts can change content or see customer data.

Want your WordPress logins secured for you? Our WordPress maintenance plans include security setup and monitoring, and every plan comes with a free hack clean-up if something ever gets through.

How to Avoid Getting Locked Out

The most common 2FA problem in WordPress support forums is not an attack. It is a site owner who loses their phone, resets it, or changes authenticator apps, and can no longer log in to their own website. In one WordPress.org support thread, a user was locked out after their codes stopped working. They had to remove the security plugin through their hosting file manager to get back in.

A lockout can take hours to fix, and it often happens at a bad time. The good news is that it is easy to prevent. These simple habits keep you in control of your own site.

  • Save the backup codes when you set up 2FA, and store them in a password manager or print them. Do not keep them only on the same phone.
  • Make sure at least two trusted people have administrator access with their own 2FA, so one person can help the other.
  • Use an authenticator app that can back up its codes to your account, so a new phone does not mean losing access.
  • Know how to log in to your hosting control panel. If everything else fails, renaming the 2FA plugin's folder in the file manager turns the plugin off so you can log in and set it up again.

Close the Other Ways Into Your Site

2FA protects the normal WordPress login page, but there are other ways to log in that some plugins do not cover. Attackers know this, and they often try these other routes instead. It is worth checking them after you turn on 2FA.

The first is XML-RPC, an older system that lets apps and services log in to WordPress. Wordfence has reported that attacks on XML-RPC happen at nearly the same rate as attacks on the normal login page. If you do not use the WordPress mobile app or a service that needs XML-RPC, turn it off with your security plugin.

The second is application passwords, which WordPress uses to let other tools connect to your site. They are separate from your normal password and may not ask for 2FA. Check the Application Passwords section in each administrator's profile and remove any that you do not recognize or no longer use.

Finally, limit login attempts so bots are blocked after several wrong passwords, and remove old user accounts that nobody uses. Each unused administrator account is one more account that attackers can try to use.

2FA Is One Part of WordPress Security

Two-factor authentication stops most login attacks, but it does not fix outdated plugins, weak hosting or malware that is already on a site. Real protection comes from 2FA together with tested updates, daily offsite backups and regular security scans.

Our WordPress maintenance checklist shows how login security fits into a full maintenance routine. If you think someone has already logged in to your site without permission, read our WordPress malware removal guide, or ask our team for help with WordPress malware removal.

Written by

Md Sayfur Rahman

A website that doesn't break, doesn't slow down, and doesn't get hacked. Sounds like a fantasy. But it's exactly what I build. After more than 14 years in the WordPress ecosystem, I've learned that a truly great website isn't just about how it looks on launch day. It's about how it performs under pressure, how easy it is to manage, and how secure it remains as time goes on.