Maybe a basin plug on a piece of thin shock cord, tied to the seatpost in a suitable way. That way when the seatpost is raised, the plug does its work, and when folding, it becomes part of the seatpost.
I like this idea. Also the duct tape can be emergency use. Thanks everyone.