Let $S$ be a base scheme and $f \colon X \to S$ and $Y \to S$ finitely presented morphisms. Suppose that $g$ is affine and $f$ is faithfully flat and separated with connected reduced geometric fibers. Also, suppose that $f$ is proper over a (topologically) dense subscheme $U$ of $S$. Is it true that every morphism $g \colon X \to Y$ over $S$ is constant (i.e., factors through a section $S \to Y$)?

The following example does not work, it hasn't geometrically connected fibers. Sorry. In general the answer is no. Take $k \subset K$, a finite extension of field (so the morphism $\operatorname{Spec}(K)\to\operatorname{Spec}(k)$ is proper). Let $X$ be an affine variety over $k$. Let now $x$ be a $K$point of $X$ that is not defined over $k$. The corresponding morphism $\operatorname{Spec}(K)\to X$ does the job. 


This is essentially the proof of the rigidity theorem. As Brian says, it is enough to show that $O_S \rightarrow f_ {\ast}O_X$ is an isomorphism. If $p \in S$, then $\mathrm{H}^0(X_p, \mathcal{O}_{X_p}) = k(p)$, because the fibers are geometrically connected and geometrically reduced. Then by Grothendieck's base change theorem, $O_S \rightarrow f_ {\ast}O_X$ is in fact an isomorphism. Edit: This does not answer Behrang's question, in view of his first comment (which should be really incorporated in the question). 

