Skip to content

Commit

Permalink
Enabled providers returns just the keys so we need the supported ones…
Browse files Browse the repository at this point in the history
… to resolve the instances
  • Loading branch information
kasparsd committed Feb 14, 2025
1 parent 19938fb commit 927408c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions class-two-factor-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -547,19 +547,20 @@ public static function get_enabled_providers_for_user( $user = null ) {
* @see Two_Factor_Core::get_enabled_providers_for_user()
*
* @param int|WP_User $user Optional. User ID, or WP_User object of the the user. Defaults to current user.
* @return array
* @return array List of provider instances.
*/
public static function get_available_providers_for_user( $user = null ) {
$user = self::fetch_user( $user );
if ( ! $user ) {
return array();
}

$enabled_providers = self::get_enabled_providers_for_user( $user );
$providers = self::get_supported_providers_for_user( $user ); // Returns full objects.
$enabled_providers = self::get_enabled_providers_for_user( $user ); // Returns just the keys.
$configured_providers = array();

foreach ( $enabled_providers as $provider_key => $provider ) {
if ( $provider->is_available_for_user( $user ) ) {
foreach ( $providers as $provider_key => $provider ) {
if ( in_array( $provider_key, $enabled_providers, true ) && $provider->is_available_for_user( $user ) ) {
$configured_providers[ $provider_key ] = $provider;
}
}
Expand Down

0 comments on commit 927408c

Please sign in to comment.