-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auto Enable 2fa when user's signup? #611
Comments
@jmattcustorio can you provide a bit more information on the flows that you'd expect as it relates to the 2FA plugin? |
Hi @jeffpaul thank you for responding to my question. Let me know if you need more information. Thank you! |
@jmattcustorio are you asking if there's a hook to require a certain 2FA method or ANY 2FA method for new users? |
I was looking for the same feature. My solution was to write the code below, which runs daily and automatically activates for all "customer" users, if not already activated, the email-based Two-Factor Authentication (2FA). <?php
// WordPress Two-Factor - Settings
// Requirements: "Two-Factor" plugin (https://wordpress.org/plugins/two-factor/ / https://github.com/WordPress/two-factor)
// Last update: 2024-07-08
if (class_exists('Two_Factor_Core')) {
// Settings
define('SENDER_EMAIL', '[email protected]');
add_filter($hook_name = 'wp_mail_from', $callback = function ($original_email_address) {return SENDER_EMAIL;}, $priority = 10, $accepted_args = 1);
// Set sender name
add_filter($hook_name = 'wp_mail_from_name', $callback = function ($original_email_from_name) {return get_option($option = 'blogname', $default_value = false);}, $priority = 10, $accepted_args = 1);
// Ensure email content is HTML
add_filter($hook_name = 'wp_mail_content_type', $callback = function ($content_type) {return 'text/html';}, $priority = 10, $accepted_args = 1);
// Customize Login Screen
add_action($hook_name = 'login_enqueue_scripts', $callback = 'two_factor_customize_login_screen', $priority = 10, $accepted_args = 1);
function two_factor_customize_login_screen()
{
?>
<style type="text/css">
/* Logo */
.login h1 a {
background-image: url("<?php echo get_option($option = 'siteurl', $default_value = false); ?>/wp-content/uploads/kaffeeart-logo.png") !important;
height: 80px !important;
width: auto !important;
background-size: contain !important;
display: block !important;
text-indent: -9999px;
}
/* Form styles */
.login #loginform {
background-color: #ECEAE3;
border: 1px solid #6565651A;
border-radius: 10px;
}
.login .privacy-policy-link {
color: #AB8C6C !important;
}
.login .privacy-policy-link:hover {
color: #BCA38A !important;
}
.login .input[type="text"],
.login .input[type="password"] {
background-color: #6565651A !important;
border: 1px solid #6565651A !important;
}
/* Background color */
body.login {
background-color: #F2F0EB !important;
}
/* Buttons */
.login .two-factor-email-resend .button,
.login .button {
border: 2px solid #262626 !important;
padding: 10px 20px !important;
border-radius: 0 !important;
transition: all 0.3s !important;
}
.login .two-factor-email-resend .button {
color: #262626 !important;
background-color: transparent !important;
}
.login .two-factor-email-resend .button:hover {
color: #FFFFFF !important;
background-color: #262626 !important;
}
.login .button {
color: #FFFFFF !important;
background-color: #262626 !important;
}
.login .wp-hide-pw,
.login .hide-if-no-js {
display: none !important;
}
/* Hide reCAPTCHA v3 */
.grecaptcha-badge {
visibility: hidden !important;
}
</style>
<script type="text/javascript">
document.addEventListener("DOMContentLoaded", function() {
var wpLink = document.querySelector(".login h1 a");
if (wpLink) {
wpLink.href = "";
}
});
</script>
<?php
}
} |
@jmattcustorio There is a filter The feature to configure the auto-enabled methods is tracked as part of that same issue so I'm going to close this as a duplicate. |
Is your enhancement related to a problem? Please describe.
We've been using the 2FA plugin for a couple of years now. One issue we're encountering is that we have to manually enable it whenever a new user signs up for our service.
Proposed Solution
automatically enable it when a new user signs up?
Designs
No response
Describe alternatives you've considered
No response
Please confirm that you have searched existing issues in this repository.
Yes
The text was updated successfully, but these errors were encountered: