Since there's been some helpful and detailed replies already, I'd like to share this Exegesis from IPV also.
Discern by Fruits, Not Gifts
True prophets obey Jesus' teachings. Like the false prophets of old (Jer 6:13-14; 8:11; 23:13-17; Ezek 13:1-16; Mic 3:5-8), those Matthew warns against in 7:15 probably proclaim a gospel of false peace, an easy way that neglects God's true demands (vv. 13-14; France 1985:147). Matthew elsewhere warns against false prophets (7:22; 24:5, 24) and apostate Christians and leaders in the church (24:12, 48-51). Jesus elsewhere applies the present denunciations of fruitless trees against the religious leaders of his day (12:33; compare 3:8, 10; 21:19; 23:3), but because his words in this context address prophets (which most Pharisees thought no longer existed in their day), one suspects that Matthew wants Christians of his own generation to take notice.
Jesus' words are not only polemic against enemies of the faith from the outside; they are also warnings to us who claim to be Jesus' followers. We dare not restrict the title "hypocrites" to Jesus' religious contemporaries (6:2, 5, 16; pace Did. 8:1-2); God's subsequent servants may share the same fate (24:51). This passage presents us with several lessons.
False Prophets and Their Teaching Pose a Real Danger to Believers (7:15)
They are like hungry wolves who disguise themselves as sheep. People in Jesus' day could disguise themselves in sheepskins in the hope of being taken for stray dogs or other animals (Jos. War 3.192). Jesus' image is, however, more graphic than that, employing hyperbole: wolves do not wear clothes, and changing one's hide was a metaphor for the impossible (Jer 13:23; Jub. 37:20). By coming in sheep's clothing, the false prophets pretend to be sheep (Acts 20:29-30) though they are in fact hungry wolves who have come to prey on sheep (compare Mt 10:16).
Some denominations that once evangelized peoples and held orthodox teachings now encompass a much wider range of moral and spiritual teaching, and many movements that remain orthodox in general nevertheless remain susceptible to dangerous winds of doctrine. We who should be challenging unjust reasoning in the world instead often find ourselves fighting a defensive battle within our own ranks. For the sake of the flock, we must exercise discernment, especially within the church.
Evaluate Prophets by Their Fruits (7:16-20) These false prophets (v. 15) claim to have prophesied, exorcised and effected miracles by Jesus' name (v. 22). Although Matthew is surely charismatic in a positive way (compare, for example, 5:12; 10:8, 40-42; 23:34), here he challenges false Christian charismatics whose disobedience Christ will finally reveal (10:26). Although some could prophesy and work signs by demonic power (for example, 2 Thess 2:9; Rev 13:13-16; compare Jer 2:8; 23:13), one could also manifest genuine gifts of God's Spirit yet be lost (1 Sam 19:24).
Once we acknowledge that God can inspire people to speak his message (and this would apply to gifts like teaching as well as prophecy), how do we discern his genuine representatives? Like his follower Paul, Jesus subordinates the gifts of the Spirit to the fruit of the Spirit (compare 1 Cor 13) and submission to Jesus' lordship (1 Cor 12:1-3). Jesus' words about fruit thus refer to repentant works (Mt 7:21; 3:8, 10), recalling Jesus' ethical teachings in 5:21-7:12.
Much of today's church may miss out on prophecy altogether, which is not a healthy situation (1 Thess 5:20). Prophecy remains a valid gift until Jesus' return (1 Cor 13:9-12), and we should seek it for our churches (1 Cor 14:1, 39; Grudem 1982; Keener 1996:79-130). But wherever the real is practiced, the counterfeit will also appear (a phenomenon I as a charismatic have witnessed frequently; compare 1 Cor 14:29; 1 Thess 5:21).
An adulterous minister may exhibit many divinely bestowed gifts-sometimes because God is answering the prayers of people in the congregation-but such ministers are unworthy of our trust as God's spokespersons as long as they continue in sin. Yet Jesus wants us to look even closer to home. Do we become so occupied with "the Lord's work" that we lose sight of the precious people God has called us to serve? Do we become so preoccupied with our mission and our gifts that we neglect a charitable attitude toward our families and other people around us?
Yet the image of the tree and the fruit also reminds us that behavior flows from character, and in Christian teaching character comes through being born again rather than merely through self-discipline (see Odeberg 1964:72). Our own best efforts at restructuring unregenerate human nature are doomed to failure (Gal 5:19-21). By contrast, a person transformed by and consistently dependent on the power of God's Spirit will live according to the traits of God's character because of God's empowerment, just as trees bear fruit according to their own kind (Gal 5:18, 22-23).
God Will Expose Our Hearts on the Day of Judgment (7:21-23)
Some people claim to accept Jesus as a great teacher, but no more than a teacher. Yet a central component of Jesus' teaching is the revelation of his identity, and in this passage as in Matthew 25:31-46, Jesus claims the role of final judge.
Churchgoers today are no more automatically saved than those who ate with Jesus in the past (as is often noted, attending a church no more makes one a Christian than entering a garage makes one a car). Not those who claim to "know" Jesus but only those who do the Father's will have any claim on Jesus (12:50). Jesus thus borrows biblical language for righteous enmity toward the wicked (Ps 6:8; 119:115) to banish them from his presence (Mt 7:23; compare 7:19). I never knew you is a formal repudiation of the person (25:12; compare 26:70, 72, 74; France 1985:149).