In addition to a written agreement signed in advance, Title 17 USC requires that the assignment fall within a group of, if I recall correctly, exactly nine kinds of commissioned work to become a valid work for hire. None of those are wedding photography. Some of the difficult workarounds, I believe, involve actually hiring the photographer as a real-live, temporary employee (reported, insured, taxed, whatever the state and federal government requires) *or* making the wedding and its photographs a part of a larger work in the form of a motion picture.
Re: Work for hire changed in 1976