We present a theory for polyelectrolyte gels that allow the effective charge of the polymer backbone to self-regulate. Using a variational approach, we obtain an expression for the free energy of gels that accounts for the gel elasticity, free energy of mixing, counterion adsorption, local dielectric constant, electrostatic interaction among polymer segments, electrolyte ion correlations, and self-consistent charge regularization on the polymer strands. This free energy is then minimized to predict the behavior of the system as characterized by the gel volume fraction as a function of external variables such as temperature and salt concentration. We present results for the volume transition of polyelectrolyte gels in salt-free solvents, solvents with monovalent salts, and solvents with divalent salts. The results of our theoretical analysis capture the essential features of existing experimental results and also provide predictions for further experimentation. Our analysis highlights the importance of the selfregularization of the effective charge for the volume transition of gels in particular, and for charged polymer systems in general. Our analysis also enables us to identify the dominant free energy contributions for charged polymer networks and provides a framework for further investigation of specific experimental systems.