There's a simpler way of doing it. You don't need to muck around with the secure system as much: partyFrame is the secure header that shows the party frame.
lua Code:
local stateMonitor = CreateFrame("Frame", nil, nil, "SecureHandlerBaseTemplate")
stateMonitor:SetFrameRef("partyHeader", partyFrame)
stateMonitor:WrapScript(stateMonitor, "OnAttributeChanged", [[
if( name ~= "state-raidmonitor" ) then return end
if( self:GetAttribute("state-raidmonitor") == "raid" ) then
self:GetFrameRef("partyHeader"):Hide()
else
self:GetFrameRef("partyHeader"):Show()
end
]])
RegisterStateDriver(stateMonitor, "raidmonitor", "[target=raid1, exists] raid; none")
That is a simplified version of what Shadowed Unit Frames does,
https://gist.github.com/6323ba8bb2a9a4365413 is the full version which let's me do things like modify the stateMonitors attributes to decide whether or not I want the feature enabled.
You have to WrapScript before you call RegisterStateDriver, because as soon as you call RegisterStateDriver it's going to check the state and it'll switch to raid (or none) before your attribute event is setup.