I figured it could work very similarly to locks.
Prerequisites: a visitor flag (new item), the master key to the gate (if locked).
Steps:
- Craft the visitor gate, an item requiring cloth (maybe wool cloth?), wood, red pigment
- While holding the visitor flag, right-click the gate you want to apply it to
- Wait for the animation. In order to reduce weird abuses, I'd suggest extending the animation to a full minute or so.
Ps. I was going to suggest a way to do the opposite as well, but I think there's some more security concerns involved and more chances for abuse. So that might be something to be considered and discussed in a different thread.