The OP doesn't want to magically hide or show frames at random. He wants to hide them when he enters combat, and frames are not yet protected when PLAYER_REGEN_DISABLED fires, which is what I originally suggested he use. Or, if he makes the parent a secure state handler like I suggested in the same post you quoted from, you don't ever need to call frame:Hide() or frame:Show() because the state driver will do it all for him based on the valid macro conditionals registered with it -- which includes checking for combat.
I suggested parenting the unit frames to a single "container" frame because it avoids (a) having to run through multiple frames and hiding and showing them all individually and (b) having to take extra steps to prevent unit frames from reappearing because their registered unit still exists, as would happen if someone joined/left your group in combat. Unit frames don't look up their chain of parentage and show everything they're parented to.
The code he posted is using Blizzard's secure templates. He's just creating the units individually instead of using a header, which for party frames (not raid frames) is totally fine. But, for the reasons I already detailed, it means that if you want to hide them under certain conditions (eg. while in combat) you can't just hide the frames -- you have to parent them to something that isn't a unit frame, and hide that.
You could actually parent them all to a secure state driver frame, that would handle hiding and showing itself without any event registration at all:
You can still position your party frames relative to the UIParent if you want (which is what you're probably doing now) or you can SetPoint and/or SetSize the container and position the individual frames relative to it instead.
Wait, what? How do you know how my unitframes work? :p I didn't even post the code on how I show/hide them. Also, why would I wanna parent them all to 1 frame? hiding it would result in every child frame getting hidden as well, what if I want to hide/show them individually? As in people leaving/joining your group.
You should never need to manually show or hide a frame when the unit comes into existence (eg. "party1" comes into existence when you invite someone to a party and they accept). If you are manually showing/hiding your frames when the unit comes into (or goes out of) existence, either your frames are not really unit frames, or you're doing it wrong.
Parenting all the party frames to one frame will let you accomplish your goal of "hide all party frames while in combat" without having to hide each frame individually, which won't work anyway for the reasons I already described.
wwwDot, your code formatting is still awful. Please stop mixing tabs and spaces. Even if they look the same in your editor, they don't look the same on the forum. You can set your editor to display tabs as the width of, say, 3 spaces, but web browsers don't have that option, and every web browser displays tabs at different widths. Ideally you should always indent with tabs, not with spaces, but if you really want to use spaces for some reason, please be consistent with them.
Also, the RegisterEvent method doesn't work that way. It only accepts one argument, the event name. If you want to register more than one event, you have to call RegisterEvent more than one time.
Joex000, you need to do several things in order to hide your party frames while you're in combat. First, you need to parent them all to a single frame:
Second, you need to register for the PLAYER_REGEN_DISABLED and PLAYER_REGEN_ENABLED events. When they fire, you need to check that you are not InCombatLockdown(), and then Hide or Show the party parent frame, not the individual unit frames. Unit frames automatically show or hide themselves based on whether the unit they're set to watch exists, so even if you hide them, they'll reappear. If you hide their parent, however, it doesn't matter if they're shown or hidden, because they don't do anything with the visibility of their parent.