It's often imagined that it was Sayyidna Umar was the one who prohibitted mut'a marriages, or temporary marriages, which are marriages with time limits written into their contracts.
Sayyidna Ali said: The Prophet peace be upon him prohibited mut’a on the day of Khaybar (Bukhari & Muslim, Arabic below).
On the day of the conquest of Makka, the Prophet peace be upon him permitted mut'a again as a rukhsa just for that day, then prohibtted it again in the same trip (Bukhari). This shows that the Prophet peace be upon him was able to make law.
Imam al-Nawawi summarizes: "It was prohibited on the day of Khaybar then made permissible again as a temporary rukhsa on the day of the Makkan conquest, then prohibitted again permanently until the Day of Judgement."
As for what is said about some Companions who did mut'a in the time of Abu Bakr and 'Umar, this would not indicate permissibility. The ulama consider that they simply did not know about the permanant prohibition. It is possible for rulings to have not been known. It was for this reason, that Sayyidna 'Umar re-announced the prohibition, and said that whoever does this again will be prosecuted.
It was said by some profligates that the Maliki school permits mut'a, which is absolutely false. Imam Malik was asked, "What if a man marries a woman with the permission of her wali and with a sadaq they agreed upon, but he married her up to a time limit of a few months or a year or two. Is that a valid marriage?" He replied, "Such a nikah would be invalid. If he marries her only up to a time period---any amount of time---then the nikah is invalid" (The Mudawwana, DKI publication, vol 1, pp 130).
Arabic text of ahadith and Malik's fatwa:
عن علي رضي الله عنه: أن رسول الله
.صلى الله عليه وسلم نهى عن نكاح المتعة، وعن لحوم الحمر الأهلية زمن خيبر.
.عن الربيع بن سبرة عن أبيه أن رسول الله صلى الله عليه وسلم نهى يوم الفتح -فتح مكة- عن متعة النساء.
قلت أرأيت إذا تزوج امرأة بإذن ولي بصداق قد سماه، تزوجها إلى أشهر أو سنة، أو سنتين أيصلح هذا النكاح؟ قال مالك: هذا النكاح باطل. إذا تزوجها إلى أجل من الآججال فهذا .النكاح باطل.