PluginProbe ʕ •ᴥ•ʔ
WP 2FA – Two-factor authentication for WordPress / 2.9.2
WP 2FA – Two-factor authentication for WordPress v2.9.2
4.0.0 1.7.1 2.0.0 2.0.1 2.1.0 2.2.0 2.2.1 2.3.0 2.4.0 2.4.1 2.4.2 2.5.0 2.6.0 2.6.1 2.6.2 2.6.3 2.6.4 2.7.0 2.8.0 2.9.0 2.9.1 2.9.2 2.9.3 3.0.0 3.0.1 3.1.0 3.1.1 3.1.1.2 trunk 1.2.0 1.3.0 1.4.0 1.4.1 1.4.2 1.5.0 1.5.1 1.5.2 1.6.0 1.6.1 1.6.2 1.7.0
wp-2fa / includes / classes / Admin / class-user-registered.php
wp-2fa / includes / classes / Admin Last commit date
Controllers 10 months ago Fly-Out 10 months ago Helpers 10 months ago Methods 10 months ago SettingsPages 10 months ago Views 10 months ago class-help-contact-us.php 10 months ago class-plugin-updated-notice.php 10 months ago class-premium-features.php 10 months ago class-settings-page.php 10 months ago class-setup-wizard.php 10 months ago class-user-listing.php 10 months ago class-user-notices.php 10 months ago class-user-profile.php 10 months ago class-user-registered.php 10 months ago index.php 10 months ago
class-user-registered.php
61 lines
1 <?php
2 /**
3 * Responsible for WP2FA user's grace periods.
4 *
5 * @package wp2fa
6 * @subpackage user-utils
7 * @copyright 2025 Melapress
8 * @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
9 * @link https://wordpress.org/plugins/wp-2fa/
10 * @since 3.0.0
11 */
12
13 namespace WP2FA\Admin;
14
15 use WP2FA\Admin\Helpers\User_Helper;
16
17 if ( ! class_exists( '\WP2FA\Admin\User_Registered' ) ) {
18 /**
19 * User_Profile - Class for handling user things such as profile settings and admin list views.
20 */
21 class User_Registered {
22
23 /**
24 * Apply 2FA Grace period
25 *
26 * @param int $user_id User id.
27 *
28 * @return void
29 *
30 * @since 3.0.0
31 */
32 public static function apply_2fa_grace_period( $user_id ) {
33 $user_id = intval( $user_id );
34 if ( User_Helper::is_user_method_in_role_enabled_methods( $user_id ) ) {
35 return;
36 } else {
37 User_Helper::remove_enabled_method_for_user( $user_id );
38 User_Helper::remove_global_settings_hash_for_user( $user_id );
39 }
40 }
41
42 /**
43 * Checks the user on role change.
44 *
45 * @param integer $user_id - The ID of the user.
46 * @param string $role - The user role.
47 * @param array $old_roles - Old roles for the user.
48 *
49 * @return void
50 *
51 * @since 3.0.0
52 */
53 public static function check_user_upon_role_change( $user_id, $role, $old_roles ) {
54 $user_id = intval( $user_id );
55 $role = sanitize_text_field( $role );
56
57 self::apply_2fa_grace_period( $user_id );
58 }
59 }
60 }
61