This is a complement to the previous answers, in what concerns lattices.
In his answer, Arturo Magidin showed that $M_3$ doesn't have the CEP and hinted that a lattice is distributive iff it has the CEP.
Later, Hugo showed that $N_5$ doesn't have the CEP either, whence non-distributive lattices don't have the CEP, claiming that with that the hint of Arturo Magidin was proven.
This was certainly an overlook of the problem since it still remains to show that distributive lattices do have the CEP.
A variety is said to have Equationally Definable Principal Congruences (EDPC, for short) if there is a conjunction $\Phi(w,x,y,z)$ of finitely many equations on four variables such that for every algebra $\mathbf A$ in that variety and every $a,b,c,d \in A$
$$(c,d) \in \Theta(a,b) \iff \mathbf A \vDash \Phi(a,b,c,d).$$
In this question there is an answer (by Berci) in which it is shown that if a variety has EDPC then it has the CEP.
In this question there is an answer of mine showing that the variety of distributive lattices has EDPC.
Hence we can conclude that distributive lattices have the CEP and that the property of having the CEP characterizes distributive lattices among all lattices as suggested.
As a side note, the formula that is being asked to prove in the last linked question is that, in a distributive lattice
$$(c,d) \in \Theta(a,b) \iff (a \wedge b \wedge c = a \wedge b \wedge d \;\text{and}\; a \vee b \vee c = a \vee b \vee d).$$
A similar and equivalent formula is, supposing $a \leq b$,
$$(c,d) \in \Theta(a,b) \iff (a \wedge c = a \wedge d \;\text{and}\; b \vee c = b \vee d),$$
where the equivalence comes from the fact that in a lattice (distributive or not), $a \sim b$ iff $a \wedge b \sim a \vee b$, for any congruence $\sim$.