PluginProbe ʕ •ᴥ•ʔ
WP 2FA – Two-factor authentication for WordPress / 2.4.2
WP 2FA – Two-factor authentication for WordPress v2.4.2
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 3 years ago Helpers 3 years ago SettingsPages 3 years ago Views 3 years ago class-help-contact-us.php 3 years ago class-premium-features.php 3 years ago class-settings-page.php 3 years ago class-settingspage.php 3 years ago class-setup-wizard.php 3 years ago class-user-listing.php 3 years ago class-user-notices.php 3 years ago class-user-profile.php 3 years ago class-user-registered.php 3 years ago class-user.php 3 years ago index.php 5 years ago
class-user-registered.php
50 lines
1 <?php
2 /**
3 * Responsible for WP2FA user's grace periods.
4 *
5 * @package wp2fa
6 * @subpackage user-utils
7 * @copyright 2023 WP White Security
8 * @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
9 * @link https://wordpress.org/plugins/wp-2fa/
10 */
11
12 namespace WP2FA\Admin;
13
14 use WP2FA\Admin\Helpers\User_Helper;
15
16 /**
17 * User_Profile - Class for handling user things such as profile settings and admin list views.
18 */
19 class User_Registered {
20
21 /**
22 * Apply 2FA Grace period
23 *
24 * @param int $user_id User id.
25 *
26 * @return void
27 */
28 public static function apply_2fa_grace_period( $user_id ) {
29 if ( User_Helper::is_user_method_in_role_enabled_methods( $user_id ) ) {
30 return;
31 } else {
32 User_Helper::remove_enabled_method_for_user( $user_id );
33 User_Helper::remove_global_settings_hash_for_user( $user_id );
34 }
35 }
36
37 /**
38 * Checks the user on role change.
39 *
40 * @param integer $user_id - The ID of the user.
41 * @param string $role - The user role.
42 * @param array $old_roles - Old roles for the user.
43 *
44 * @return void
45 */
46 public static function check_user_upon_role_change( $user_id, $role, $old_roles ) {
47 self::apply_2fa_grace_period( $user_id );
48 }
49 }
50