Title: Two factor authentication doesn&#8217;t work for some users
Last modified: September 26, 2022

---

# Two factor authentication doesn’t work for some users

 *  Resolved [mattheo](https://wordpress.org/support/users/mattheo/)
 * (@mattheo)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/two-factor-authentication-doesnt-work-for-some-users/)
 * Hello,
    I’m testing the 2FA feature of your plugin and I noticed that it works
   only for users that have an Admin or Editor roles.
 * When I try to login with aa a “custom editor” user I don’t see any 2FA on the
   login and I can enter the wp-admin without any verification.
 * Is there a way to set the two factor authentication for every single user, even
   the minor or custom ones?

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

 *  Plugin Support [Georgi Ganchev](https://wordpress.org/support/users/georgiganchev/)
 * (@georgiganchev)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/two-factor-authentication-doesnt-work-for-some-users/#post-16043569)
 * Hello [@mattheo](https://wordpress.org/support/users/mattheo/)
 * By default, the 2FA feature is applied only for the Admin and Editor user roles.
 * If you would like to use this feature for additional roles, we have prepared 
   a filter that you can add under your theme’s functions.php file. You can observe
   the filter here:
 *     ```
       add_filter( 'sg_security_2fa_roles', 'add_user_roles_to_2fa' );
       function add_user_roles_to_2fa( $roles ) {
           $roles[] = 'your_role';
           return $roles;
       }
       ```
   
 * You can add additional fields if you would like more roles to be protected. You
   just need to substitute “**your_role**” with the exact user role that you would
   like to use.
 * Best regards,
    Georgi Ganchev Technical Support
 *  Thread Starter [mattheo](https://wordpress.org/support/users/mattheo/)
 * (@mattheo)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/two-factor-authentication-doesnt-work-for-some-users/#post-16110116)
 * Hi Georgi,
    many thanks for your support
 * We had positive results using your code in a single WP installation.
 * We also used that code in a WP multisite installation.
 * We put it in every functions.php of that installation, because we’ve got different
   themes.
 * In some of those themes the code it works, in some other ones the whole theme
   goes in error, not showing the subsite.
 * Have you an idea how we could do to avoid errors and to reach the result?
    -  This reply was modified 3 years, 7 months ago by [mattheo](https://wordpress.org/support/users/mattheo/).
 *  Plugin Support [Delyan Delov](https://wordpress.org/support/users/delyandelov/)
 * (@delyandelov)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/two-factor-authentication-doesnt-work-for-some-users/#post-16110221)
 * Hi [@mattheo](https://wordpress.org/support/users/mattheo/),
 * I am afraid that we cannot provide you with any meaningful information without
   being able to investigate the errors you are receiving.
 * Could you provide us with the site URL where the theme error is visible so we
   can further look into it?
 *  Thread Starter [mattheo](https://wordpress.org/support/users/mattheo/)
 * (@mattheo)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/two-factor-authentication-doesnt-work-for-some-users/#post-16110511)
 * We added this code to functions.php in the folder /theme in the main site (the
   first one) of the multisite installation.
 * We added the same code in functions.php in the folder /theme of every site of
   the multisite installation.
 *     ```
       add_filter( 'sg_security_2fa_roles', 'add_user_roles_to_2fa' );
       function add_user_roles_to_2fa( $roles ) {
           $roles[] = 'editoruerlimitatoadalcunicontenuti';
           $roles[] = 'editorsoloedit';
           return $roles;
       }
       ```
   
 * in both cases the 2fa hasn’t been worked.
 * The fact is that: in our TEST MULTI-SITE (which is an exact copy of the live 
   multisite) we used a specular code that is working properly, with the 2fa active
   for our custom users.
 *     ```
       add_filter( 'sg_security_2fa_roles', 'add_user_roles_to_2fa' );
       function add_user_roles_to_2fa( $roles ) {
           $roles[] = 'editorformazioneintegrale';
           $roles[] = 'wpseo_editor';
           $roles[] = 'psicologo';
           return $roles;
       }
       ```
   
 * I hope these elements can help you to understand our problem.
 * Thanks,
    M
    -  This reply was modified 3 years, 7 months ago by [mattheo](https://wordpress.org/support/users/mattheo/).
 *  Plugin Support [Delyan Delov](https://wordpress.org/support/users/delyandelov/)
 * (@delyandelov)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/two-factor-authentication-doesnt-work-for-some-users/#post-16111056)
 * The typical WordPress Mulstisite installation does not provide separate theme
   folders. Could you provide more information regarding the exact setup you are
   using so we can try to recreate it?
 * Also, could you please copy the error message you are receiving on your subsites?
 *  Thread Starter [mattheo](https://wordpress.org/support/users/mattheo/)
 * (@mattheo)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/two-factor-authentication-doesnt-work-for-some-users/#post-16113447)
 * Our WP multisite installation has some customizations in styles and functions
   for its different subsites.
 * For this reason we have files in /wp-content/theme/subsite1/, that is the leading
   one and some customized files (for example functions.php, style.css and specific
   template files…) in /wp-content/theme/subsite2/ or /wp-content/theme/subsite3/
   and so on.
 * The error is that your code is working on test area (pretty well, even if some
   roles it is not able to manage, we didn’t know why), but it is not working on
   the live site at all.
 *  Plugin Support [Delyan Delov](https://wordpress.org/support/users/delyandelov/)
 * (@delyandelov)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/two-factor-authentication-doesnt-work-for-some-users/#post-16114740)
 * Thank you for the provided information, [@mattheo](https://wordpress.org/support/users/mattheo/).
 * I have conducted several tests with single and Multisite setups and found a small
   issue in the plugin that prevents the 2FA to work on the subsites. I have already
   notified our developers regarding the case and they will fix the issue in the
   upcoming plugin version.
 * For the time being, the 2FA will work only with the Editor and Administrator 
   roles even if you use the filter provided above.
 * Regarding the issue you are experiencing with the live site compared with the
   testing site, most probably there is some different configuration that is causing
   the issue. I would advise you to check the server configuration as well if they
   are located on different servers. Also, make sure our plugin is up-to-date on
   your test site as well as on the live site.
    -  This reply was modified 3 years, 7 months ago by [Delyan Delov](https://wordpress.org/support/users/delyandelov/).
    -  This reply was modified 3 years, 7 months ago by [Delyan Delov](https://wordpress.org/support/users/delyandelov/).
 *  Thread Starter [mattheo](https://wordpress.org/support/users/mattheo/)
 * (@mattheo)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/two-factor-authentication-doesnt-work-for-some-users/#post-16117214)
 * Thank you for your response.
 * It’s a strange result the one we are obtaining, because, with this code in the
   test site we are able to let woking the role 1 (editorformazioneintegrale) and
   the role 2 (wpseo_editor), but not the role 3 (psicologo)
 *     ```
       add_filter( 'sg_security_2fa_roles', 'add_user_roles_to_2fa' );
       function add_user_roles_to_2fa( $roles ) {
           $roles[] = 'editorformazioneintegrale';
           $roles[] = 'wpseo_editor';
           $roles[] = 'psicologo';
           return $roles;
       }
       ```
   
    -  This reply was modified 3 years, 7 months ago by [mattheo](https://wordpress.org/support/users/mattheo/).
 *  Plugin Support [Delyan Delov](https://wordpress.org/support/users/delyandelov/)
 * (@delyandelov)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/two-factor-authentication-doesnt-work-for-some-users/#post-16117457)
 * I have tried to recreate the described behavior on my end but to no avail. If
   the 2FA does not work only for one role, probably it is not defined properly 
   or there is an error in the code.
 * I would recommend waiting for the new plugin release where the above-mentioned
   issue will be fixed and then performing another test on your end.
 *  Thread Starter [mattheo](https://wordpress.org/support/users/mattheo/)
 * (@mattheo)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/two-factor-authentication-doesnt-work-for-some-users/#post-16117631)
 * Thank you very much for your fast response.
 * I’ve seen that you’re updating quite frequently.
    Do you know how much time does
   this fix require?
 * Regards,
    M.
 *  Plugin Support [Delyan Delov](https://wordpress.org/support/users/delyandelov/)
 * (@delyandelov)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/two-factor-authentication-doesnt-work-for-some-users/#post-16117735)
 * I am afraid that I cannot provide an ETA for when the next version will be released.
 *  [Tim Nolte](https://wordpress.org/support/users/tnolte/)
 * (@tnolte)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/two-factor-authentication-doesnt-work-for-some-users/#post-16179652)
 * [@delyandelov](https://wordpress.org/support/users/delyandelov/) I believe this
   fix you did for multisite actually [broke 2FA](https://wordpress.org/support/topic/lastest-release-broke-2fa-verification/)
   now. I think whatever that “fix” was needs to be reevaluated as I am now totally
   locked out of my entire network of sites due potentially to whatever was trying
   to be fixed for this issue.
 *  Plugin Support [Delyan Delov](https://wordpress.org/support/users/delyandelov/)
 * (@delyandelov)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/two-factor-authentication-doesnt-work-for-some-users/#post-16181330)
 * Hi [@tnolte](https://wordpress.org/support/users/tnolte/),
 * I have noticed that you already created a new topic regarding the issue you are
   experiencing:
 * [https://wordpress.org/support/topic/lastest-release-broke-2fa-verification/](https://wordpress.org/support/topic/lastest-release-broke-2fa-verification/)
 * As suggested in the above thread, please post a ticket through SiteGround’s Helpdesk
   so we can investigate the case further.
 *  Thread Starter [mattheo](https://wordpress.org/support/users/mattheo/)
 * (@mattheo)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/two-factor-authentication-doesnt-work-for-some-users/#post-16199317)
 * Hi Delyan,
 * I saw you released a new version of the plugin (v. 1.3.6).
    Did my issue regarding
   the WP multisites installation has been solved with the update?
 * Many thanks.
    M.
 *  Plugin Support [Daniela Ivanova](https://wordpress.org/support/users/daniellaivanova/)
 * (@daniellaivanova)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/two-factor-authentication-doesnt-work-for-some-users/#post-16199488)
 * The issue should be resolved in the latest version of the plugin (v. 1.3.6).
 * Best regards,
    Daniela Ivanova

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

The topic ‘Two factor authentication doesn’t work for some users’ is closed to new
replies.

 * ![](https://ps.w.org/sg-security/assets/icon-256x256.gif?rev=2971855)
 * [Security Optimizer - The All-In-One Protection Plugin](https://wordpress.org/plugins/sg-security/)
 * [Support Threads](https://wordpress.org/support/plugin/sg-security/)
 * [Active Topics](https://wordpress.org/support/plugin/sg-security/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/sg-security/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/sg-security/reviews/)

## Tags

 * [2fa](https://wordpress.org/support/topic-tag/2fa/)
 * [authentication](https://wordpress.org/support/topic-tag/authentication/)
 * [login](https://wordpress.org/support/topic-tag/login/)
 * [users](https://wordpress.org/support/topic-tag/users/)

 * 15 replies
 * 5 participants
 * Last reply from: [Daniela Ivanova](https://wordpress.org/support/users/daniellaivanova/)
 * Last activity: [3 years, 6 months ago](https://wordpress.org/support/topic/two-factor-authentication-doesnt-work-for-some-users/#post-16199488)
 * Status: resolved