Ali bin Abi Talhah narrated from Ibn `Abbas, about,
﴿ إِنَّ ٱلَّذِينَ ءَامَنُواْ وَٱلَّذِينَ هَادُواْ وَٱلنَّصَـٰرَىٰ وَٱلصَّـٰبِـِٔينَ مَنۡ ءَامَنَ بِٱللَّهِ وَٱلۡيَوۡمِ ٱلۡأَخِرِ ﴾
(Verily, those who believe and those who are Jews and Christians, and Sabians, whoever believes in Allah and the Last Day) that Allah revealed the following Ayah afterwards,
﴿ وَمَن يَبۡتَغِ غَيۡرَ ٱلۡإِسۡلَـٰمِ دِينً۬ا فَلَن يُقۡبَلَ مِنۡهُ وَهُوَ فِى ٱلۡأَخِرَةِ مِنَ ٱلۡخَـٰسِرِينَ ﴾
(And whoever seeks religion other than Islam, it will never be accepted of him, and in the Hereafter he will be one of the losers) (3:85).
This statement by Ibn `Abbas indicates that Allah does not accept any deed or work from anyone, unless it conforms to the Law of Muhammad that is, after Allah sent Muhammad . Before that, every person who followed the guidance of his own Prophet was on the correct path, following the correct guidance and was saved.