Skip to content

Instantly share code, notes, and snippets.

@herbie4
Created August 8, 2023 17:25
Show Gist options
  • Save herbie4/35cdba7d14a2c2c17dfe2ab2fa5a2308 to your computer and use it in GitHub Desktop.
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.
<?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