Let $G$ be a nilpotent group of class c. Prove that for each $x \in Z_2(G)$ the map $\theta_x: G \rightarrow Z(G)$ defined by $\theta_x(g)=[g,x]$ is a homomorphism with kernel $C_G(x)$.
A hint is given referencing a useful identity on commutors:
$[xy,z]=[x,z]^y[y,z]$
Where the exponent y denotes conjugation by y.
I am stuck showing that this map is a homomorphism:
Let $g_1,g_2 \in G$, then $\theta_x(g_1g_2)=[g_1g_2,x]=[g_1,x]^{g_2}[g_2,x]$
So I could show that this function preserves the algebraic structure an is thus a homomorphism if It were true that $[g_1,x]^{g_2}=[g_1,x]$ then I would be done but this is obviously not true and I don't know what I did wrong.
To show that $[g_1,x]^{g_2} = [g_1,x]$, we try to show that $[g_1,x] \in Z(G)$ (as pointed out in comments). First note that by definition, $Z_2(G)/Z(G) = Z(G/Z(G))$. So if we show that $gZ(G) = [g_1,x]Z(G), (\text{assuming}\ g =[g_1,x] \in G)$ is a trivial element in $G/Z(G)$ then we are done. But this is true because $[g_1,x]Z(G) = [g_1Z(G),xZ(G)]$ and $x \in Z_2(G) \Rightarrow xZ(G) \in Z(G/Z(G)) \Rightarrow [\alpha, xZ(G)] = 1 \ \forall\ \alpha \in G/Z(G) \Rightarrow [g_1Z(G), xZ(G)] = 1 \in G/Z(G)$ and hence we are done.