pH-dependent interactions guide the folding and gate the transmembrane pore of the beta-barrel membrane protein OmpG.