Skip to content

Commit

Permalink
Add a helper to check if the method is supported for the user
Browse files Browse the repository at this point in the history
  • Loading branch information
kasparsd committed Feb 14, 2025
1 parent 63323e4 commit 58e30e0
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions providers/class-two-factor-provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,19 @@ abstract public function validate_authentication( $user );
*/
abstract public function is_available_for_user( $user );

/**
* If this provider should be available for the user.
*
* @param WP_User|int $user WP_User object, user ID or null to resolve the current user.
*
* @return bool
*/
public static function is_supported_for_user( $user = null ) {
$providers = Two_Factor_Core::get_supported_providers_for_user( $user );

return isset( $providers[ self::class ] );
}

/**
* Generate a random eight-digit string to send out as an auth code.
*
Expand Down

0 comments on commit 58e30e0

Please sign in to comment.