the example of munafiq ubai is always quoted in the wrong context. yes Prophet Muhammad Saw' prayed his funeral, after this the following Verse was revealed. So to quote the example of Ubai's funeral for any incident after the revelation is totally irrelevant.
"And never (O Muhammad) pray (funeral prayer) for any of them (i.e. hypocrites) that dies." (9. 84)
Secondly, Hazrat Umar ra' and Ubai's own son were ready to kill the munafiq but Prophet Muhammad saw' didn't allowed them out of some reasons, the reason is explained in the Hadith below.
Volume 006, Book 060, Hadith Number 428.
Narated By Jabir bin 'Abdullah : We were in a Ghazwa (Sufyan once said, in an army) and a man from the emigrants kicked an Ansari man (on the buttocks with his foot). The Ansari man said, "O the Ansar! (Help!)" and the emigrant said. "O the emigrants! (Help!) Allah's Apostle heard that and said, "What is this call for, which is characteristic of the period of ignorance?" They said, "O Allah's Apostle! A man from the emigrants kicked one of the Ansar (on the buttocks with his foot)." Allah's Apostle said, "Leave it (that call) as is a detestable thing." 'Abdullah bin Ubai heard that and said, 'Have the (the emigrants) done so? By Allah, if we return Medina, surely, the more honourable will expel there-from the meaner." When this statement reached the Prophet. 'Umar got up an, said, "O Allah's Apostle! Let me chop off the head of this hypocrite ('Abdullah bin Ubai)!" The Prophet said "Leave him, lest the people say that Muhammad kills his companions." The Ansar were then more in number than the emigrants when the latter came to Medina, but later on the emigrant increased.