Hiding MainMenuBar and StanceBar in 11.0.5

I have a small personal addon that previously worked which hides the MainMenuBar and StanceBar since they cannot be hidden in the default game.

I used this small function

local function HideMMB()
RegisterAttributeDriver(StanceBar, “state-visibility”, “hide”)
RegisterAttributeDriver(MainMenuBar, “state-visibility”, “hide”)
end

Which is called on PLAYER_ENTERING_WORLD, however now since patch I disconnect randomly and get this error:

AddOn ‘MY_ADDON_NAME’ tried to call the protected function ‘SecureStateDriverManager:SetAttribute()’

And then insta kicks me out of the game. Does anyone know how to update this to work in 11.0.5?

If they are simple frames a

MainMenuBar:Hide()

and

StanceBar:Hide()

Should do it.

certain events load them back and so thats not enough unfortunatly, hence why I have them registered like this

The ghetto solution is to hide them on each refresh, could check if they are visible beforehand.

Not realy clean but i do the same for the talking heads.

The chat bot says this could work:

frame:SetScript("OnShow", function(self)
    print("Frame is now visible!") -- hide here
end)