If $f$ is not 1-1 then $|f(x)-f(y)|$ does not define a metric on $X$ as you have distinct points having distance zero from one another. Constant functions are uniformly continuous, so your guess is wrong.
I believe the answer is that $f$ be $1-1$ and proper... that is the inverse image of any compact set under $f$ is compact. For metric spaces compactness is equivalent to sequential compactness. If $f$ is not proper then there is a sequence $x_n \in X$ with $f(x_n)$ convergent even though $x_n$ isn't.
On the other hand if $f$ is $1-1$ and proper, let $x_n$ be a Cauchy sequence in the "$f$-metric". This means in particular the sequence $f(x_n)$ is convergent in $\mathbb{R}$ and has a limit $y$. The set $\{f(x_n)\}\cup \{y\}$ is compact in $\mathbb{R}$ so it has compact inverse image. Since $x_n$ is in this set, it has a convergent subsequence $x_{n_k}$ Since $f$ is continuous this sequence is convergent in the $f$ metric, and if a subsequence of a Cauchy sequence converges then so does the Cauchy sequence. Therefore $X$ in the "$f$-metric$ is complete.
There are probably other solutions that work, and since this is a homework problem the correct solution is the one that fits in with where you are in the class. Also I took some not so baby steps in my proof, so you need to fill in the details to be at the proper level to get credit for the solution.