Title: PHP warning on login
Last modified: December 14, 2021

---

# PHP warning on login

 *  Resolved [misatotremor](https://wordpress.org/support/users/misatotremor/)
 * (@misatotremor)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/php-warning-on-login/)
 * There is a PHP warning upon user login:
    `Warning: Undefined array key "enforcement-
   policy" in plugins/wp-2fa/includes/classes/Admin/User.php on line 362`
 * IMHO the line should contain an isset check or use `WP2FA::get_wp2fa_setting`.
 * If it helps this is an install updated from WP 2FA v1.
    -  This topic was modified 4 years, 9 months ago by [misatotremor](https://wordpress.org/support/users/misatotremor/).
      Reason: Leftover formatting in message

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

 *  Plugin Contributor [robertabela](https://wordpress.org/support/users/robert681/)
 * (@robert681)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/php-warning-on-login/#post-15169265)
 * Hello [@misatotremor](https://wordpress.org/support/users/misatotremor/)
 * Thank you very much for using our plugin and for posting this issue.
 * Would you be able to give us more details so we can understand the context of
   the issue? For example, when is this warning being triggered? The more information
   you can share with us the better we can understand the issue.
 * Looking forward to hearing from you.
 *  Thread Starter [misatotremor](https://wordpress.org/support/users/misatotremor/)
 * (@misatotremor)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/php-warning-on-login/#post-15181114)
 * This warning is triggered upon login. It happens for users with 2FA enabled and
   those who don’t have it enabled.
 * On our sites the options `wp_2fa_policy` value is `a:0:{}` therefor the current
   code tries to access a non-existing array key. I could fix this in my install
   by changing [https://plugins.trac.wordpress.org/browser/wp-2fa/trunk/includes/classes/Admin/User.php#L361](https://plugins.trac.wordpress.org/browser/wp-2fa/trunk/includes/classes/Admin/User.php#L361)
   and #L362 from
    `$settings = SettingsUtils::get_option( WP_2FA_POLICY_SETTINGS_NAME);``
   if ( ! is_array( $settings ) || 'do-not-enforce' === $settings['enforcement-policy']){`
   to `if ( 'do-not-enforce' === WP2FA::get_wp2fa_setting( 'enforcement-policy' )){`.
    -  This reply was modified 4 years, 9 months ago by [misatotremor](https://wordpress.org/support/users/misatotremor/).
 *  Plugin Contributor [robertabela](https://wordpress.org/support/users/robert681/)
 * (@robert681)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/php-warning-on-login/#post-15186698)
 * Thank you for the update [@misatotremor](https://wordpress.org/support/users/misatotremor/)
 * We are looking into this and will make sure it is addressed in the next update.
   In the meantime, if you have any other questions or feedback, please get in touch.
 * Have a great day and all the best this festive season.
 *  [KAnet](https://wordpress.org/support/users/kanetweb/)
 * (@kanetweb)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/php-warning-on-login/#post-15190949)
 * Same issue here:
    [… date and time …] PHP Warning: Undefined array key “enforcement-
   policy” in /home/…../public_html/wp-content/plugins/wp-2fa/includes/classes/Admin/
   User.php on line 362
 * Great plugin by the way
 *  Plugin Contributor [robertabela](https://wordpress.org/support/users/robert681/)
 * (@robert681)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/php-warning-on-login/#post-15225732)
 * Hello [@kanetweb](https://wordpress.org/support/users/kanetweb/) and [@misatotremor](https://wordpress.org/support/users/misatotremor/)
 * We have identified and fixed the issue.
 * We have prepared a version update of the plugin with the fix, which you can install.
   Please[ download this version update of WP 2FA](https://www.wpwhitesecurity.com/downloads/support/wp-2fa_210.zip)
   and install it.
 * We have tested it ourselves, however, it would be great if you can also confirm
   the fix.
 * Looking forward to hearing from you.
 *  Thread Starter [misatotremor](https://wordpress.org/support/users/misatotremor/)
 * (@misatotremor)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/php-warning-on-login/#post-15225747)
 * Hello [@robert681](https://wordpress.org/support/users/robert681/)
 * Thank you very much for the update! I can confirm this fixes the issue for us.

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

 The topic ‘PHP warning on login’ is closed to new replies.

 * ![](https://ps.w.org/wp-2fa/assets/icon-256x256.png?rev=2961533)
 * [WP 2FA - Two-factor authentication for WordPress](https://wordpress.org/plugins/wp-2fa/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-2fa/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-2fa/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-2fa/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-2fa/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-2fa/reviews/)

 * 6 replies
 * 3 participants
 * Last reply from: [misatotremor](https://wordpress.org/support/users/misatotremor/)
 * Last activity: [4 years, 8 months ago](https://wordpress.org/support/topic/php-warning-on-login/#post-15225747)
 * Status: resolved