contestada

What is it called when you go through something to prevent another person to go through that same thing? Like go in their place.

It's an idiom, I think, and I really need to know.
thank you.