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.
quran:18:24

Except ˹when adding˺, "If Allah wills." And remember your Lord when you forget ˹it˺ and say, "Perhaps my Lord will guide me to what is nearer than this to right conduct."  

without ˹adding˺, ‘If God will’, in other words, unless ˹firmly˺ adhering to the will of God, exalted be He, by saying, ‘If God will’ (inshā’a’Llāh). And remember your Lord, that is, ˹remember˺ His will, making ˹things˺ conditional on it, if you forget, to make ˹things˺ conditional on it: mentioning it after forgetting ˹it˺ is the equal ˹in validity˺ to mentioning it at the time of the statement — as al-Hasan ˹al-Basrī˺ and others have said — as long as the person is still in the ˹same˺ place ˹in which he made the statement˺. And say, ‘May be my Lord will guide me to ˹something˺ closer ˹in time˺ than this, ˹closer˺ than the story of the People of the Cave, as an indication of ˹the truth of˺ my prophethood, by way of guidance, and God indeed did so.
القرآن:١٨:٢٤

إِلَّا أَنْ يَشَاءَ اللَّهُ ۚ وَاذْكُرْ رَبَّكَ إِذَا نَسِيتَ وَقُلْ عَسَىٰ أَنْ يَهْدِيَنِ رَبِّي لِأَقْرَبَ مِنْ هَٰذَا رَشَدًا  

{إلا يشاء الله} أي إلا ملتبسا بمشيئة الله تعالى بأن تقول إن شاء الله {واذكر ربك} أي مشيئته معلقا بها {إذا نسيت} ويكون ذكرها بعد النسيان كذكرها مع القول الحسن وغيره ما دام في المجلس {وقل عسى أن يهدين ربي لأقرب من هذا} من خبر أهل الكهف في الدلالة على نبوتي {رشدا} هداية وقد فعل الله ذلك.