Created
August 8, 2023 17:25
-
-
Save herbie4/35cdba7d14a2c2c17dfe2ab2fa5a2308 to your computer and use it in GitHub Desktop.
HHdev Force 2fa email for all users. Use as mu-plugin. Needs the https://wordpress.org/plugins/two-factor/ plugin to be active.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: HHdev Force 2fa email for all users | |
* Version: 1.0.1 | |
* Description: Needs 2FA plugin to work. Forces alle users to 2fa with email. | |
* Plugin URI: https://haha.nl/wordpress-plug-in-op-maat/ | |
*/ | |
/* | |
There is also an open issue for enabling 2FA for all users which includes a temporary solution for doing that through a filter: | |
*/ | |
// set the 2fa forced. | |
add_filter( | |
'two_factor_enabled_providers_for_user', | |
function( $providers ) { | |
if ( empty( $providers ) && class_exists( 'Two_Factor_Email' ) ) { | |
$providers[] = 'Two_Factor_Email'; | |
} | |
return $providers; | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment