• Resolved dassels43

    (@dassels43)


    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 325

    For 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();
    }
    }

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Lucian Padureanu

    (@lucianwpwhite)

    Hello @dassels43,

    I’m really sorry to hear about this unexpected experience!

    To help us investigate and replicate the issue on our end, could you kindly share a few more details about your setup and what you’re encountering?

    1. Environment Info
      a) What version of PHP are you using?
      b) Which version of the WP 2FA plugin and WordPress core are currently active?
    2. When Did the Issue Start?
      Is this something you noticed after installing the plugin for the first time, or did it start after a recent update to WP 2FA or another plugin/theme?
    3. User Login Flow
      a) What 2FA method are your users using when this issue occurs?
      b) Can you describe your site’s network or user management setup a bit more — for example, how the custom role wholesaler is created and whether it’s assigned automatically or manually?
      c) Are you using the native log in form of WordPress when this occurs, or a custom log in form? It would be useful to understand in which of the following scenario this happens.

    The more detail you can provide (including any steps to reproduce the issue), the better we’ll be able to assist.

    Looking forward to your reply so we can get to the bottom of this!

    Thread Starter dassels43

    (@dassels43)

    Hi Lucian,

    Thanks for the follow-up! Your questions allowed us to do further testing which revealed the issue lies with a custom login form we have. The native wp-login does a check for roles before running 2FA code, so we added that in to the custom form to prevent running 2FA without a role present which seems to have fixed the issue.

    Plugin Contributor robertabela

    (@robert681)

    I am glad to read you found the source of the problem @dassels43

    Should you have any other questions, please do not hesitate to ask. May I ask you for a small favour? Please do not forget to spare a minute to rate the plugin and our service. These ratings are really helpful.

    Thank you and have a great weekend.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Uncaught Exception: Role provided does not exists – “wholesaler”’ is closed to new replies.