What your professor meant to say takes just one line which looks like that
$$
\|g\|_{L^p}^p=\int\limits_{\Omega}|h(z)-\overline{h}|\,dz\leqslant
C\!\!\int\limits_{\Omega}|\nabla h(z)|\,dz\leqslant
Cp\!\!\int\limits_{\Omega}|\nabla g(z)|^{p-1}|\nabla g(z)|\,dz\leqslant
\|g\|_{L^p}^{p-1}\|\nabla g\|_{L^p}
$$
where the Hölder's inequality is applied with the conjugate exponents $p$ and
$p'=p/(p-1)$. But to follow this way one should have chosen $h(z)-\overline{h}=|g(z)|^p\,$ which immediately implies $g\equiv 0$, i.e., $u\equiv\overline{u}=const$. Taking just $h(z)=|g(z)|^p$ doesn't work. A miscalculation can be corrected if only one takes $\,h(z)=g(z)|g(z)|^{p-1}$ in order to start with the Poincaré-like inequality
$$
\int\limits_{\Omega}|h(z)|\,dz\leqslant
C\!\!\int\limits_{\Omega}|\nabla h(z)|\,dz\quad\forall\, h\in W^{1,1}(\Omega)\,\colon
\int\limits_{\Omega} h(z)|h(z)|^{-1/p'}\,dz=0. \tag{$\ast$}
$$
Proving $(\ast)$ by inverse argument amounts to a trivial exercise due to the obvious fact that $h(z)|h(z)|^{-1/p'}=g(z)=u(z)-\overline{u}$, and hence
$$
\int\limits_{\Omega} h(z)|h(z)|^{-1/p'}\,dz=0 \iff
\int\limits_{\Omega} g(z)\,dz=\int\limits_{\Omega} \bigl(u(z)-\overline{u}\bigr)\,dz=0.
$$
But it is rather doubtful whether any direct proof of $(\ast)$ be known as yet.