For a secret door I don't really know, but I'm going to decribe how you would do it for a normal door. Logically, they should be handled in the same way.
If you want your door to suddenly swing closed when the player collides with an area; then using
SetSwingDoorLocked(string& asName, bool abLocked, bool abEffects);
should do the trick
If you want it to close more slowly first and then lock, then use some
AddPropForce(string& asName, float afX, float afY, float afZ, string& asCoordSystem);
first, and then after a second or so use the one above here to set it locked.