WPCOM_VIP_Support_User::action_wp_login PHP Method

action_wp_login() public method

Hooks the wp_login action to make any verified VIP Support user a Super Admin!
public action_wp_login ( $user_login, WP_User $user ) : void
$user_login The login for the logging in user
$user WP_User The WP_User object for the logging in user
return void
    public function action_wp_login($user_login, WP_User $user)
    {
        if (!is_multisite()) {
            return;
        }
        // If the user:
        // * Is an inactive support user
        // * Is a super admin
        // …revoke their powers
        if ($this->user_has_vip_support_role($user->ID, false) && is_super_admin($user->ID)) {
            require_once ABSPATH . '/wp-admin/includes/ms.php';
            revoke_super_admin($user->ID);
            return;
        }
        if (!$this->user_has_vip_support_role($user->ID)) {
            // If the user is a super admin, but has been demoted to
            // the inactive VIP Support role, we should remove
            // their super powers
            if (is_super_admin($user->ID) && $this->user_has_vip_support_role($user->ID, false)) {
                // This user is NOT VIP Support, remove
                // their powers forthwith
                require_once ABSPATH . '/wp-admin/includes/ms.php';
                revoke_super_admin($user->ID);
            }
            return;
        }
        if (!$this->user_has_verified_email($user->ID)) {
            return;
        }
        if (is_super_admin($user->ID)) {
            return;
        }
        if (!is_super_admin($user->ID)) {
            // This user is VIP Support, verified, let's give them
            // great power and responsibility
            require_once ABSPATH . '/wp-admin/includes/ms.php';
            grant_super_admin($user->ID);
        }
    }