Brothers and sisters, if someone is caught in a sin, you who live by the Spirit should restore that person gently. But watch yourselves, or you also may be tempted.
Church discipline is a touchy subject, especially in a church-shopping era where someone who really doesn't want to repent can go to another church where either (1) he can be a stealth congregant and not be noted for his sin or (2) they accepts his habits. At least one denomination has been founded to fill the latter.
Assuming the person wants to do a 180, the key word is gently. Bringing the person up front and saying "Joe here got caught with his pants down with his secretary. Pity the scumbag and steer clear of him until we say otherwise" isn't the way to go. In some cases, especially when it was an elder of some sort that strayed, you might need some sort of public acknowledgement of what happened and why they're stepping aside from leadership for a time.
However, the goal isn't to shame, it's to rebuild and redirect.
The last part of the verse is good to note; trying to disciple someone recovering from bad habits does run the risk of getting you dragged into their world. For instance, someone getting moved off of a p0rn habit might have the mentor having to fight off his own issues on that front as they help another guy ditch the vice.