Uncaught Exception: Role provided does not exists – “wholesaler”
-
Running Multisite here. Not all sites will have the same registered roles. If a user from a different site tries to log in, they get critical error. Here is the stack trace:
PHP Fatal error: Uncaught Exception: Role provided does not exists - "wholesaler" in [,,,]/public_html/wp-content/plugins/wp-2fa/includes/classes/Admin/Controllers/class-settings.php:325
Stack trace: 0 [,,,]/public_html/wp-content/plugins/wp-2fa/includes/classes/Admin/Controllers/class-settings.php(345): WP2FA\Admin\Controllers\Settings::get_enabled_providers_for_role() 1 [,,,]/public_html/wp-content/plugins/wp-2fa/includes/classes/Admin/Methods/class-backup-codes.php(241): WP2FA\Admin\Controllers\Settings::is_provider_enabled_for_role() 2 [,,,]/public_html/wp-includes/class-wp-hook.php(324): WP2FA\Methods\Backup_Codes::remove_backup_methods_for_user() 3 [,,,]/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters() 4 [,,,]/public_html/wp-includes/plugin.php(517): WP_Hook->do_action() 5 [,,,]/public_html/wp-content/plugins/wp-2fa/includes/classes/Admin/Helpers/class-user-helper.php(2145): do_action() 6 [,,,]/public_html/wp-content/plugins/wp-2fa/includes/classes/Admin/Helpers/class-user-helper.php(2058): WP2FA\Admin\Helpers\User_Helper::remove_backup_methods() 7 [,,,]/public_html/wp-content/plugins/wp-2fa/includes/classes/Admin/Helpers/class-user-helper.php(2167): WP2FA\Admin\Helpers\User_Helper::update_meta_if_necessary() 8 [,,,]/public_html/wp-content/plugins/wp-2fa/includes/classes/Admin/Helpers/class-user-helper.php(1060): WP2FA\Admin\Helpers\User_Helper::set_proper_user() 9 [,,,]/public_html/wp-content/plugins/wp-2fa/includes/classes/Admin/Helpers/class-user-helper.php(1107): WP2FA\Admin\Helpers\User_Helper::get_grace_period() 10 [,,,]/public_html/wp-content/plugins/wp-2fa/includes/classes/Authenticator/class-login.php(496): WP2FA\Admin\Helpers\User_Helper::is_user_locked() 11 [,,,]/public_html/wp-includes/class-wp-hook.php(324): WP2FA\Authenticator\Login::run_authentication_check() 12 [,,,]/public_html/wp-includes/plugin.php(205): WP_Hook->apply_filters() 13 [,,,]/public_html/wp-includes/user.php(203): apply_filters() 14 [,,,]/public_html/wp-includes/class-wp-hook.php(324): wp_authenticate_username_password() 15 [,,,]/public_html/wp-includes/plugin.php(205): WP_Hook->apply_filters() 16 [,,,]/public_html/wp-includes/pluggable.php(623): apply_filters() 17 [,,,]/public_html/wp-includes/user.php(109): wp_authenticate() 18 [,,,]/public_html/wp-login.php(1323): wp_signon() 19 {main}thrown in [,,,]/public_html/wp-content/plugins/wp-2fa/includes/classes/Admin/Controllers/class-settings.php on line 325For now I’ve bypassed it but shouldn’t give an error for that – users can end up on the wrong subsite and try logging in not realizing it. That shouldn’t crash the site.
Here is the function for anyone else having this issue:
public static function get_enabled_providers_for_role( string $role ) {
if ( WP_Helper::is_role_exists( $role ) ) {
self::get_all_roles_providers();
return self::$all_providers_for_roles[ $role ];
} elseif ( '' === $role ) {
return array();
} else {
// Let's disable exception for now....
// throw new \Exception( 'Role provided does not exists - "' . $role . '"' ); // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped
return array();
}
}
The topic ‘Uncaught Exception: Role provided does not exists – “wholesaler”’ is closed to new replies.