Little bit hard to say when I don't know where your custom code is located. Usually you are hiding items by setting the Visible property to False using forms builtin Set_Item_Property. This should work both from the forms itself and any attached pll library. The syntax is:
Set_Item_Property(<block_name.item_name>, VISIBLE, PROPERTY_FALSE);