diff --git a/class-two-factor-core.php b/class-two-factor-core.php index 99033a70..6bc7c2e4 100644 --- a/class-two-factor-core.php +++ b/class-two-factor-core.php @@ -257,10 +257,12 @@ private static function get_providers_classes() { * Get all enabled two-factor providers. * * @since 0.1-dev + * @since 0.10.0 Added the $user_id parameter. * + * @param int|null $user_id Optional. User ID. * @return array */ - public static function get_providers() { + public static function get_providers( $user_id = null ) { $providers = self::get_providers_registered(); /** @@ -269,10 +271,11 @@ public static function get_providers() { * This lets third-parties either remove providers (such as Email), or * add their own providers (such as text message or Clef). * - * @param array $providers A key-value array where the key is the class name, and - * the value is the path to the file containing the class. + * @param array $providers A key-value array where the key is the class name, and + * the value is the path to the file containing the class. + * @param int|null $user_id The user ID. */ - $providers = apply_filters( 'two_factor_providers', $providers ); + $providers = apply_filters( 'two_factor_providers', $providers, $user_id ); // FIDO U2F is PHP 5.3+ only. if ( isset( $providers['Two_Factor_FIDO_U2F'] ) && version_compare( PHP_VERSION, '5.3.0', '<' ) ) { @@ -499,7 +502,7 @@ public static function get_enabled_providers_for_user( $user = null ) { return array(); } - $providers = self::get_providers(); + $providers = self::get_providers( $user->ID ); $enabled_providers = get_user_meta( $user->ID, self::ENABLED_PROVIDERS_USER_META_KEY, true ); if ( empty( $enabled_providers ) ) { $enabled_providers = array(); @@ -527,7 +530,7 @@ public static function get_available_providers_for_user( $user = null ) { return array(); } - $providers = self::get_providers(); + $providers = self::get_providers( $user->ID ); $enabled_providers = self::get_enabled_providers_for_user( $user ); $configured_providers = array(); @@ -590,7 +593,7 @@ public static function get_primary_provider_for_user( $user = null ) { return null; } - $providers = self::get_providers(); + $providers = self::get_providers( $user->ID); $available_providers = self::get_available_providers_for_user( $user ); // If there's only one available provider, force that to be the primary. @@ -1834,7 +1837,7 @@ public static function user_two_factor_options( $user ) {
- $object ) : ?> + ID ) as $provider_key => $object ) : ?>