Find all functions $g:\mathbb{R}\to\mathbb{R}$ with $g(x+y)+g(x)g(y)=g(xy)+g(x)+g(y)$ for all $x,y$.
I think the solutions are $0, 2, x$. If $g(x)$ is not identically $2$, then $g(0)=0$. I'm trying to show if $g$ is not constant, then $g(1)=1$. I have $g(x+1)=(2-g(1))g(x)+g(1)$. So if $g(1)=1$, we can show inductively that $g(n)=n$ for integer $n$. Maybe then extend to rationals and reals.
Substituting an infinitesimal $y=dx$ gives
$g(x)+g(x)g(0)=g(0)+g(x)+g(0)$ or $g(x)g(0)=2 g(0)$
and
$g'(x)+g(x)g'(0)=g'(0)x+g'(0)$,
for a smooth function $g(x)$. The first equation implies either $g(0)=0$ or $g(x)=2$. Solving the differential equation with the condition $g(0)=0$ gives
$g(x)=\frac{1}{k}((1-k)e^{-kx}+k(x+1)-1),$
where $k=g'(0)\ne0$. If $g'(0)=0$, then $g(x)=0$. Any smooth solution of your equality with $g(0)=0$ and $g'(0)\ne0$ must be of this form for some $k=g'(0)$. I get $g(x)=x$ for $k=1$. You can check if that is the only option by substituting $g(x)$ into your equality.