plugin-icon

Two Factor

作者:WordPress.org·
Enable Two-Factor Authentication (2FA) using time-based one-time passwords (TOTP), Universal 2nd Factor (U2F), email, and backup verification codes.
评级
4.8
版本
0.15.0
活跃安装
100K
最后更新
Feb 17, 2026
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

  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
    • 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)
  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

  • 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.

有关更多历史,请参阅这篇文章

动作和过滤器

以下列出该插件提供的动作和过滤器钩子:

  • two_factor_providers 过滤器:将覆盖可用的双重身份验证提供方式,例如电子邮件和基于时间的一次性密码。数组值为双重身份验证方式的 PHP 类名。
  • two_factor_providers_for_user filter overrides the available two-factor providers for a specific user. Array values are instances of provider classes and the user object WP_User is available as the second argument.
  • two_factor_enabled_providers_for_user 过滤器:将覆盖提供给用户启用的双重身份验证方式清单。第一个参数为启用的方式提供类名数组作为值,第二个参数为用户 ID。
  • two_factor_user_authenticated 动作:接收已登录的 WP_User 对象作为第一个参数,用在身份验证工作流之后确定登录的用户。
  • two_factor_user_api_login_enable filter restricts authentication for REST API and XML-RPC to application passwords only. Provides the user ID as the second argument.
  • two_factor_email_token_ttl filter overrides the time interval in seconds that an email token is considered after generation. Accepts the time in seconds as the first argument and the ID of the WP_User object being authenticated.
  • two_factor_email_token_length filter overrides the default 8 character count for email tokens.
  • two_factor_backup_code_length filter overrides the default 8 character count for backup codes. Provides the WP_User of the associated user as the second argument.
  • two_factor_rest_api_can_edit_user filter overrides whether a user’s Two-Factor settings can be edited via the REST API. First argument is the current $can_edit boolean, the second argument is the user ID.
  • 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_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 after two_factor_after_authentication_prompt).
免费基于付费套餐
通过安装,您同意 WordPress.com 服务条款第三方插件条款
目前已测试版本
WordPress 6.9.4
这个插件是可用的下载,适用于您的站点。