Skip to content

Profile settings section rendered regardless of whether any providers are enabled #662

@Player701

Description

@Player701

Describe the bug

If there are no two-factor providers enabled, the corresponding profile section is still rendered on the user settings page. This creates a visual inconsistency in scenarios where two-factor authentication needs to be disabled for a specific user or group of users.

Expected behavior: Users should not see the two-factor section in their profile settings if there are no providers currently available.

Actual behavior: Users always see the two-factor section in their profile settings even if there are no providers currently available. (See screenshot)

Steps to Reproduce

This filter will disable all providers:

add_filter(
    'two_factor_providers',
    function ( $providers ) {
        return [];
    },
    9999
);

Of course this code is for demonstration purposes only. Actual code would likely use two_factor_enabled_providers_for_user and perform some check on the user ID first. The result, however, is the same.

Screenshots, screen recording, code snippet

Image

Environment information

WordPress 6.7.1, plugin version 0.11.0

Please confirm that you have searched existing issues in this repository.

Yes

Please confirm that you have tested with all plugins deactivated except Two-Factor.

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions