Two Factor

Description

The Two-Factor plugin adds an extra layer of security to your WordPress login by requiring users to provide a second form of authentication in addition to their password. This helps protect against unauthorized access even if passwords are compromised.

Setup Instructions

Important: Each user must individually configure their two-factor authentication settings.

For Individual Users

  1. Navigate to your profile: Go to « Users » « Your Profile » in the WordPress admin
  2. Find Two-Factor Options: Scroll down to the « Two-Factor Options » section
  3. Choose your methods: Enable one or more authentication providers (noting a site admin may have hidden one or more so what is available could vary):
    • Authenticator App (TOTP) – Use apps like Google Authenticator, Authy, or 1Password
    • Email Codes – Receive one-time codes via email
    • Backup Codes – Generate one-time backup codes for emergencies
    • Dummy Method – For testing purposes only (requires WP_DEBUG)
  4. Configure each method: Follow the setup instructions for each enabled provider
  5. Set primary method: Choose which method to use as your default authentication
  6. Save changes: Click « Update Profile » to save your settings

For Site Administrators

  • Plugin settings: The plugin provides a settings page under « Settings Two-Factor » to configure which providers should be disabled site-wide.
  • User management: Administrators can configure 2FA for other users by editing their profiles
  • Security recommendations: Encourage users to enable backup methods to prevent account lockouts

Available Authentication Methods

Authenticator App (TOTP) – Recommended

  • Security: High – Time-based one-time passwords
  • Setup: Scan QR code with authenticator app
  • Compatibility: Works with Google Authenticator, Authy, 1Password, and other TOTP apps
  • Best for: Most users, provides excellent security with good usability

Backup Codes – Recommended

  • Security: Medium – One-time use codes
  • Setup: Generate 10 backup codes for emergency access
  • Compatibility: Works everywhere, no special hardware needed
  • Best for: Emergency access when other methods are unavailable

Email Codes

  • Security: Medium – One-time codes sent via email
  • Setup: Automatic – uses your WordPress email address
  • Compatibility: Works with any email-capable device
  • Best for: Users who prefer email-based authentication

FIDO U2F Security Keys

  • Deprecated and removed due to loss of browser support.

Dummy Method

  • Security: None – Always succeeds
  • Setup: Only available when WP_DEBUG is enabled
  • Purpose: Testing and development only
  • Best for: Developers testing the plugin

Important Notes

HTTPS Requirement

  • All methods work on both HTTP and HTTPS sites

Browser Compatibility

  • TOTP and email methods work on all devices and browsers

Account Recovery

  • Always enable backup codes to prevent being locked out of your account
  • If you lose access to all authentication methods, contact your site administrator

Security Best Practices

  • Use multiple authentication methods when possible
  • Keep backup codes in a secure location
  • Regularly review and update your authentication settings

For more information about two-factor authentication in WordPress, see the WordPress Advanced Administration Security Guide.

Pour un historique complet, voyez cet article.

Actions & Filtres

Voici une liste des crochets d’action et de filtre fournis par l’extension :

  • Le filtre two_factor_providers remplace les fournisseurs d’authentification à deux facteurs disponibles, tels que les mots de passe à usage unique basés sur l’heure et les e-mails. Les valeurs du tableau sont les noms de classe PHP des fournisseurs d’authentification à deux facteurs.
  • Le filtre two_factor_providers_for_user remplace les fournisseurs à deux facteurs disponibles pour un compte spécifique. Les valeurs du tableau sont des instances de classes de fournisseurs et l’objet compte WP_User est disponible en tant que deuxième argument.
  • Le filtre two_factor_enabled_providers_for_user remplace la liste des fournisseurs à deux facteurs activés pour un compte. Le premier argument est un tableau contenant les noms de classe des fournisseurs activés en tant que valeurs, le deuxième argument est l’ID du compte.
  • L’action two_factor_user_authenticated qui reçoit l’objet WP_User connecté comme premier argument afin de déterminer le compte connecté immédiatement après le processus d’authentification.
  • Le filtre two_factor_user_api_login_enable limite l’authentification pour l’API REST et XML-RPC aux mots de passe d’application uniquement. Fournit l’ID du compte comme deuxième argument.
  • Le filtre two_factor_email_token_ttl remplace l’intervalle de temps en secondes pendant lequel un jeton d’e-mail est pris en compte après sa génération. Il accepte le temps en secondes comme premier argument et l’ID de l’objet WP_User en cours d’authentification.
  • Le filtre two_factor_email_token_length surcharge le nombre par défaut de 8 caractères pour les jetons d’e-mail.
  • Le filtre two_factor_backup_code_length surcharge le nombre de caractères par défaut de 8 pour les codes de récupération. Fournit le WP_User du compte associé en tant que deuxième argument.
  • Le filtre two_factor_rest_api_can_edit_user détermine si les réglages de double authentification d’un compte peuvent être modifiés via l’API REST. Le premier argument est la valeur booléenne actuelle $can_edit, le second argument est l’ID du compte.
  • two_factor_before_authentication_prompt action which receives the provider object and fires prior to the prompt shown on the authentication input form.
  • two_factor_after_authentication_prompt action which receives the provider object and fires after the prompt shown on the authentication input form.
  • two_factor_after_authentication_input action which receives the provider object and fires after the input shown on the authentication input form (if form contains no input, action fires immediately after two_factor_after_authentication_prompt).
  • two_factor_login_backup_links filters the backup links displayed on the two-factor login form.

Redirect After the Two-Factor Challenge

To redirect users to a specific URL after completing the two-factor challenge, use WordPress Core built-in login_redirect filter. The filter works the same way as in a standard WordPress login flow:

add_filter( 'login_redirect', function( $redirect_to, $requested_redirect_to, $user ) {
    return home_url( '/dashboard/' );
}, 10, 3 );

Captures d’écrans

FAQ

Quelles versions de PHP et WordPress l’extension Two-Factor prend-t’elle en charge ?

Cette extension prend en charge les deux dernières versions majeures de WordPress et la version minimale de PHP prise en charge par ces versions de WordPress.

Comment envoyer un retour ou obtenir de l‘aide pour un bogue ?

Le meilleur endroit pour signaler des bogues, suggérer des fonctionnalités ou faire part de tout autre commentaire (non lié à la sécurité) est la page Two Factor GitHub issues. Avant de soumettre un nouveau problème, veuillez rechercher les problèmes existants afin de vérifier si quelqu’un d’autre a déjà signalé le même retour.

Où puis-je signaler des bogues de sécurité ?

Les contributeurs et contributrices de l’extension ainsi que la communauté WordPress prennent les bogues de sécurité très au sérieux. Nous apprécions vos efforts pour divulguer vos découvertes de manière responsable et nous ferons tout notre possible pour reconnaître vos contributions.

Pour signaler un problème de sécurité, veuillez consulter le programme WordPress HackerOne.

What if I lose access to all my authentication methods?

If you have backup codes enabled, you can use one of those to regain access. If you don’t have backup codes or have used them all, you’ll need to contact your site administrator to reset your account. This is why it’s important to always enable backup codes and keep them in a secure location.

Can I use this plugin with WebAuthn?

The plugin previously supported FIDO U2F, which was a predecessor to WebAuthn. There is an open issue to add WebAuthn support here: https://github.com/WordPress/two-factor/pull/427

Is there a recommended way to use passkeys or hardware security keys with Two-Factor?

Yes. For passkeys and hardware security keys, you can install the Two-Factor Provider: WebAuthn plugin: https://wordpress.org/plugins/two-factor-provider-webauthn/ . It integrates directly with Two-Factor and adds WebAuthn-based authentication as an additional two-factor option for users.

Avis

14 juin 2026 1 réponse
It's an excellent plugin; I use it on all my sites.
10 juin 2026 1 réponse
The basic options expected:1. I must be able to use any authentication app.2. An option to use email as 2nd auth.But this plugin also have backup code.
28 mai 2026 4 réponses
This plugin requires individual users to manage 2FA. Individual users can remove 2FA from their profile at any time leaving that account vulnerable. An admin would need to check regularly that this hasn't been removed. There is discussion about a custom function to force a user back to the profile page. I tested this. A user can still leave the account with 2FA off, albeit they cannot navigation anywhere but the profile page. However, in this state a bad actor can login with a password only to the unprotected account, then configure 2FA to their own device, this then removes the redirect and therefore undermines the entire process. This is a significant flaw. However, the plugin can protect a single admin account but any sort of user hierarchy is not protected.
7 mai 2026 1 réponse
Not only did it work well for my use case with a customer who wanted to offer optional 2fa, but when i asked about customizing the code validation page i had a response in minutes. Very impressive. Worked well with a theme my login branded site.
27 avril 2026 1 réponse
Fonctionne parfaitement, simple et fiable
23 avril 2026 1 réponse
I am in version 6.6.2 of WordPress and in multisite network version. Is it possible to activate your plugin despite the constraint tested up to 6.9.1, please? I can't activate it at the network level?
Lire les 210 avis

Contributeurs/contributrices & développeurs/développeuses

« Two Factor » est un logiciel libre. Les personnes suivantes ont contribué à cette extension.

Contributeurs