diff --git a/class-two-factor-core.php b/class-two-factor-core.php index 857ddb34..80df4e25 100644 --- a/class-two-factor-core.php +++ b/class-two-factor-core.php @@ -1841,12 +1841,11 @@ public static function user_two_factor_options( $user ) { wp_enqueue_style( 'user-edit-2fa', plugins_url( 'user-edit.css', __FILE__ ), array(), TWO_FACTOR_VERSION ); $enabled_providers = array_keys( self::get_available_providers_for_user( $user ) ); - $primary_provider_key = self::get_primary_provider_key_selected_for_user( $user ); // This is specific to the current session, not the displayed user. $show_2fa_options = self::current_user_can_update_two_factor_options(); - if ( ! $show_2fa_options ) { + if ( $providers && ! $show_2fa_options ) { $url = add_query_arg( 'redirect_to', urlencode( self::get_user_settings_page_url( $user->ID ) . '#two-factor-options' ), @@ -1860,12 +1859,12 @@ public static function user_two_factor_options( $user ) { ); } - printf( - '
', - $show_2fa_options ? '' : 'disabled="disabled"' - ); + if ( empty( $providers ) ) { + $notices['notice two-factor-notice-no-providers-supported'] = esc_html__( 'No providers are available for your account.', 'two-factor' ); + } - if ( 1 === count( $enabled_providers ) ) { + // Suggest enabling a backup method if only method is enabled and there are more available. + if ( count( $providers ) > 1 && 1 === count( $enabled_providers ) ) { $notices['warning two-factor-warning-suggest-backup'] = esc_html__( 'To prevent being locked out of your account, consider enabling a backup method like Recovery Codes in case you lose access to your primary authentication method.', 'two-factor' ); } ?> @@ -1876,9 +1875,34 @@ public static function user_two_factor_options( $user ) {

+ +

- +

+ +
> @@ -1931,15 +1955,6 @@ public static function user_two_factor_options( $user ) {