This question touches a lot of different copyright issues; here's the basic overview (under US law) followed by how I think it applies:
(1) The author owns the copyright. If it's a work made for hire, then the employer owns it. A work made for hire is (1) a work an employee prepares OR (2) certain special types of works as long as the parties agree, in a signed writing, that the work is a work for hire. Here's a good summary of the work for hire doctrine: http://copyright.gov/circs/circ09.pdf
(2) The copyright code requires that all transfers be in writing and signed by the owner. Under US law, there has to be a signed written agreement in order to transfer copyright. So if the work for hire doctrine doesn't apply, the person who wrote the code owns the copyright. This is true even if you paid that person to write the code. No writing, no transfer.
(3) There's some case law stating that a click-through agreement is enough to transfer ownership. At least one federal court of appeals (4th Circuit) has indicated that this requirement of a writing might be satisfied with a click through agreement. The case is Metropolitan Regional Info Sys. v. American Home Realty Network, 722 F.3d 591 (4th Cir. 2013). That might make it a little easier to comply with.
(4) Derivative works. When a person creates a new work based on someone else's work, that's called a derivative work. The author of the original material is the only person who can authorize another to create a derivative work. But the copyright in the derivative work is separate - the author of a derivative work (not the author of the original) owns the copyright in the derivative work. Good information on that here: http://www.finnegan.com/resources/articles/articlesdetail.aspx?news=9cbb473b-f87b-47eb-8d4b-0202ad56343a
So getting to the scenario you laid out: The contributor is probably creating a derivative work by taking the original code and adding new material. Assuming there's no written agreement to the contrary, the contributor owns the copyright in the derivative work. Doesn't matter if money has changed hands, doesn't matter that the original author owns (and continues to own) the rights in the original work - the contributor owns the rights in the derivative work they created unless there's a written agreement to the contrary.
If you want to change that result, the Metropolitan Regional case gives you something; if you have a click-through agreement stating that the contributor is transferring ownership, that might be enough to put the copyright back in the hands of the original author.