VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: razor7 on January 29, 2024, 19:53:02 PM

Title: [SOLVED] Can't remove user in VM 4.2.6
Post by: razor7 on January 29, 2024, 19:53:02 PM
Hi! reviewing code in User model I suggest this change, because if not, the $_JUser instance is null in line 1685 giving error Call to a member function delete() on null

This code should be changed...
                if (self::getSuperAdminCountS() <= 1) {
                    // Prevent deletion of the only Super Admin
                    //$_u = JUser::getInstance($userId);
                    $_JUser = JUser::getInstance($userId);
                    if (in_array(8,$_JUser->groups)) {
                        vmError('COM_VIRTUEMART_USER_ERR_LASTSUPERADMIN');
                        $_status = false;
                        continue;
                    }
                }

To this
                $_JUser = JUser::getInstance($userId);

                if (self::getSuperAdminCountS() <= 1) {
                    // Prevent deletion of the only Super Admin
                    //$_u = JUser::getInstance($userId);
                    if (in_array(8,$_JUser->groups)) {
                        vmError('COM_VIRTUEMART_USER_ERR_LASTSUPERADMIN');
                        $_status = false;
                        continue;
                    }
                }
Title: Re: Can't remove user in VM 4.2.6
Post by: Milbo on February 06, 2024, 20:19:00 PM
Alright, fixed. thank you.