Two Factor
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. There are no site-wide settings for this plugin.
For Individual Users
- Navigate to your profile: Go to « Users » → « Your Profile » in the WordPress admin
- Find Two-Factor Options: Scroll down to the « Two-Factor Options » section
- 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
- FIDO U2F Security Keys – Use physical security keys (requires HTTPS)
- Backup Codes – Generate one-time backup codes for emergencies
- Dummy Method – For testing purposes only (requires WP_DEBUG)
- Configure each method: Follow the setup instructions for each enabled provider
- Set primary method: Choose which method to use as your default authentication
- Save changes: Click « Update Profile » to save your settings
For Site Administrators
- No global settings: This plugin operates on a per-user basis only. For more, see GH#249.
- 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
- Security: High – Hardware-based authentication
- Setup: Register physical security keys (USB, NFC, or Bluetooth)
- Requirements: HTTPS connection required, compatible browser needed
- Browser Support: Chrome, Firefox, Edge (varies by key type)
- Best for: Users with security keys who want maximum security
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
- FIDO U2F Security Keys require an HTTPS connection to function
- Other methods work on both HTTP and HTTPS sites
Browser Compatibility
- FIDO U2F requires a compatible browser and may not work on all devices
- 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_providersremplace 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_userremplace les fournisseurs à deux facteurs disponibles pour un compte spécifique. Les valeurs du tableau sont des instances de classes de fournisseurs et l’objet compteWP_Userest disponible en tant que deuxième argument. - Le filtre
two_factor_enabled_providers_for_userremplace 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_authenticatedqui reçoit l’objetWP_Userconnecté 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_enablelimite 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_ttlremplace 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’objetWP_Useren cours d’authentification. - Le filtre
two_factor_email_token_lengthsurcharge le nombre par défaut de 8 caractères pour les jetons d’e-mail. - Le filtre
two_factor_backup_code_lengthsurcharge le nombre de caractères par défaut de 8 pour les codes de récupération. Fournit leWP_Userdu compte associé en tant que deuxième argument. - Le filtre
two_factor_rest_api_can_edit_userdé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_promptaction which receives the provider object and fires prior to the prompt shown on the authentication input form.two_factor_after_authentication_promptaction which receives the provider object and fires after the prompt shown on the authentication input form.two_factor_after_authentication_inputaction which receives the provider object and fires after the input shown on the authentication input form (if form contains no input, action fires immediately aftertwo_factor_after_authentication_prompt).
