Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
bayhaqi:3195Abū Zakariyyā b. Abū Isḥāq And ʾAbū Bakr Aḥmad b. al-Ḥasan > Abū al-ʿAbbās Muḥammad b. Yaʿqūb > Baḥr b. Naṣr > Quriʾ > Ibn Wahb Akhbark ʿAbdullāh b. ʿUmar Wamālik b. Anas > Nāfiʿ > ʿAbdullāh b. ʿUmar

[Machine] Whoever forgets a prayer from his prayers, and he only remembers it while behind the imam, then when the imam says the salutation, he should perform the prayer that he forgot, and then perform another prayer after the other prayer. Ibn Wahb, Malik, Layth bin Sa`d, and Yahya bin Abdullah bin Salim said the same. The Sheikh, may Allah have mercy on him, said that repeating the prayer that he prayed with the imam according to Ash-Shafi'i, may Allah have mercy on him, is recommended, not obligatory. And Allah knows best.  

البيهقي:٣١٩٥أَخْبَرَنَاهُ أَبُو زَكَرِيَّا بْنُ أَبِي إِسْحَاقَ وَأَبُو بَكْرٍ أَحْمَدُ بْنُ الْحَسَنِ قَالَا ثنا أَبُو الْعَبَّاسِ مُحَمَّدُ بْنُ يَعْقُوبَ ثنا بَحْرُ بْنُ نَصْرٍ قَالَ قُرِئَ عَلَى ابْنِ وَهْبٍ أَخْبَرْكَ عَبْدُ اللهِ بْنُ عُمَرَ وَمَالِكُ بْنُ أَنَسٍ عَنْ نَافِعٍ أَنَّ عَبْدَ اللهِ بْنَ عُمَرَ قَالَ

مَنْ نَسِيَ صَلَاةً مِنْ صَلَوَاتِهِ فَلَمْ يَذْكُرْهَا إِلَّا وَهُوَ وَرَاءَ الْإِمَامِ فَإِذَا سَلَّمَ الْإِمَامُ فَلْيُصَلِّ الصَّلَاةَ الَّتِي نَسِيَهَا ثُمَّ لِيُصَلِّ بَعْدُ الصَّلَاةَ الْأُخْرَى قَالَ ابْنُ وَهْبٍ وَقَالَ مَالِكٌ وَاللَّيْثُ بْنُ سَعْدٍ وَيَحْيَى بْنُ عَبْدِ اللهِ بْنِ سَالِمٍ مِثْلَهُ قَالَ الشَّيْخُ رَحِمَهُ اللهُ وَإِعَادَةُ الصَّلَاةِ الَّتِي صَلَّاهَا مَعَ الْإِمَامِ عِنْدَ الشَّافِعِيِّ رَحِمَهُ اللهُ اسْتِحْبَابٌ لَا إِيجَابٌ وَاللهُ أَعْلَمُ