Shrek drunk the vial along with Donkey and by morning they were a human and a horse, the effect of the potion also had effect on Fiona turning her back to a human.
Shrek was told by Puss that if a kiss was not taken by midnight, then the effects would wear off, turning them back, but if one kisses their true love the potion's effects will be permanent.
After Shrek enjoys being a human he goes to see Fiona but as Shrek and Fiona go different ways, Fiona suspiciously thinks that Prince Charming is Shrek.
After Shrek lets Fiona go (told by The Fairy Godmother), he decides to let Fiona be happy with Charming.
After Shrek goes back and defeating The Fairy Godmother, he decides to stay as a human but Fiona decides she wants to be with the ogre she married and at midnight the three all transform back into ogres and donkey as Donkey is sad to be back where he is, Shrek tells him he still looks like a noble steed to him.