For the user setting to work the code snippet that runs in response to state change needs to reference the setting in a variable in its restricted environment; in the code I provided it is stored in "raidhideparty". After initialization and whenever the user setting changes it must be propagated into the restricted enviroment using :Execute, which is the purpose of the 3rd code extract in my first post, which effectively sets "ridehideparty" to be equal to the value in the user setting variable. That part could also be written like this for clarity (with the appropriate CVar used):
lua Code:
RaidPartyHandler:Execute("raidhideparty = " .. tostring(GetCVarBool("hidePartyInRaid")));
RaidPartyHandler:SetAttribute("state-unitexists", UnitExists("raid1"));