2FA Login Security is a standalone WordPress plugin focused on two-factor authentication. This repository started as a fork of Wordfence Login Security and is being pared down into a smaller plugin with fewer moving parts.
This README covers the plugin's purpose, installation, day-to-day usage, and local development workflow. The user-facing setup guide from docs/how-to.md is also included here so the main README can stand on its own.
The current codebase is centered on:
- TOTP-based two-factor authentication for WordPress users.
- Role-based 2FA activation and grace-period enforcement.
- Remember-device support.
- XML-RPC hardening by recommendation (disable XML-RPC at theme or server level).
- Multisite-aware settings and scheduling behavior.
The fork is moving away from earlier upstream integrations and bundled extras. In particular, this repository is being cleaned up to remove Wordfence-core coupling, WooCommerce integration, shortcode-specific flows, reCAPTCHA behavior, and other legacy paths that are not part of the core 2FA functionality.
- WordPress 6.0+
- PHP 8.1+
- A TOTP authenticator app such as Google Authenticator, FreeOTP, 1Password, Authy, Microsoft Authenticator, or another compatible app
- Upload the plugin to your site's
wp-content/plugins/directory, or install it through the WordPress admin. - Activate the plugin in the WordPress Plugins screen.
- Open the
Login Securityarea in wp-admin. - Review the settings, configure any role requirements, and activate 2FA for the accounts that need it.
- Upload the plugin to the network's plugins directory.
- Network activate it.
- Super administrators can manage the plugin from Network Admin.
- Users on individual sites can manage their own 2FA settings when their role and permissions allow it.
- Uses standard TOTP authenticator apps instead of SMS.
- Supports activation per user.
- Supports role-based enforcement.
- Includes one-time recovery codes.
- Supports remembering a trusted device for a limited period.
The previous XML-RPC options were removed from this fork.
Reason: XML-RPC is a frequent brute-force and abuse target, and the safer default for most modern WordPress sites is to disable XML-RPC completely unless a specific integration requires it. Instead of carrying extra plugin toggles for a legacy endpoint, this plugin now focuses on core 2FA behavior and recommends turning XML-RPC off at the theme or infrastructure layer.
Example (theme-level): add this to your active theme's functions.php:
<?php
add_filter('xmlrpc_enabled', '__return_false');If your site relies on XML-RPC for a specific workflow, keep it enabled only as needed and restrict access at the edge (WAF, reverse proxy, or allowlist rules).
- Grace-period notifications for roles that must enable 2FA.
- Admin-side controls to activate, deactivate, and regenerate recovery codes for users.
- Last-login and related user-management support in the plugin UI.
This section folds the user guide from docs/how-to.md into the main README.
Two-factor authentication adds a second proof of identity to the login process. In practice, that usually means you know your password and you also have access to an authenticator app on a phone, tablet, or another device. Both are required before access is granted.
This plugin uses Time-Based One-Time Passwords, or TOTP. Your authenticator app generates a short code that changes every 30 seconds. After entering your normal password, you enter the current code from the app.
Before you begin, install an authenticator app if you do not already use one. Common options include:
- Google Authenticator
- FreeOTP Authenticator
- 1Password
- LastPass Authenticator
- Microsoft Authenticator
- Authy
- Any other app that supports TOTP
To enable 2FA:
- Open the
Login Securitypage in WordPress admin. - Open your authenticator app and create a new entry.
- Scan the QR code shown on the page.
- If you are on the same mobile device as the site, use the manual setup code shown below the QR code instead.
- Download the recovery codes and store them somewhere safe.
- Enter the six-digit code from your authenticator app.
- Click
Activate.
If this is your first 2FA setup on the site, test it in another browser or a private window before ending your current session.
The normal login flow is:
- Enter your username and password.
- Submit the login form.
- Enter the six-digit code from your authenticator app when prompted.
- Complete login.
If you use 2FA on multiple sites, make sure you are reading the code for the correct site entry in your app.
The plugin also supports the combined-password flow used by this codebase:
- Enter your username.
- Enter your password.
- Immediately append the current TOTP code to the end of the password in the same field.
- Submit the login form.
Example:
- Password:
w0rdf3nce#! - Current code:
233455 - Combined entry:
w0rdf3nce#!233455
Recovery codes are fallback login codes for when you lose access to your authenticator device or remove the stored account by mistake.
- Each code is single-use.
- Recovery codes are longer than the usual 6-digit TOTP code.
- You should save or print them when you first activate 2FA.
To log in with a recovery code:
- Enter your username and password.
- When prompted for a
2FA Code, enter one recovery code. - Complete login.
Example recovery code:
5199 5c24 77dc 0ed7
If you use most of your recovery codes or no longer trust the saved copy, generate a new set from the Login Security page. Generating a new set invalidates the old set.
To disable 2FA on your own account:
- Log in to WordPress.
- Open the
Login Securitypage. - Click
Deactivate.
To disable 2FA for another user:
- Open the
Usersscreen in WordPress admin. - Find the user.
- Click the
2FAlink below the username. - On the management screen for that user, click
Deactivate.
Source assets live in src/ and build into plain filenames under css/ and js/.
Available npm scripts:
npm run watchruns webpack in watch mode.npm run devruns a one-off development build.npm run buildruns a production build.npm run translate:make-potregenerates the POT file.npm run translate:make-phpgenerates translation PHP files.
Asset cache busting is handled by the WordPress enqueue version parameter, not by hashed filenames.
Composer is used for development tools in this repository.
Available Composer scripts:
composer phpcsruns PHP_CodeSniffer with the local ruleset.composer phpcbfruns the automatic fixer.composer rectorruns Rector.composer rector:dry-runpreviews Rector changes.
- The plugin bootstrap now loads PHP files directly with
require_oncein a fixed order instead of using the older autoloader. - The codebase is still mid-cleanup in a few areas, so some docs and legacy internals are being updated incrementally.
2fa-login-security.php: plugin bootstrapclasses/controller/: runtime controllers and integration logicclasses/model/: domain models, settings storage, crypto, request helpers, and view helpersclasses/utility/: lower-level helper classesviews/: PHP-rendered admin and management templatessrc/: editable source assetscss/andjs/: built browser assetsdocs/: extra project documentation
- User guide: docs/how-to.md
- WordPress.org-style plugin readme: readme.txt
This repository is licensed under GPL-2.0-or-later.