The Pied Piper appears briefly in the first film, among the fairy tale creatures exiled in Shrek's swamp, where he rallies many rats with his enchanted flute.
In Shrek Forever After, he is hired by Rumpelstiltskin to capture the ogres by forcing them to dance and follow him with his enchanted flute. He can handle different species (rats, ogres, witches...) or even objects (Rumpelstiltskin's socks) by setting the "target" dial of his flute. He never speaks and instead uses his flute to communicate. The Piper has no voice, but the flute performance was done by Jeremy Steig (original author William Steig's son).