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.
suyuti:2648a

“When you pass by the gardens of Paradise, then feast.” I said: “O Messenger of Allah, and what are the gardens of Paradise?” He said, “The Masajid.” I said: “And what is feasting, O Messenger of Allah?” He said: “‘Glory is to Allah, (Subḥān Allāh)’ and ‘All praise is due to Allah, (Al-Ḥamdulillāh)’ and ‘None has the right to be worshipped but Allah, (Lā Ilāha Illallāh)’ and ‘Allah is the Greatest (Allāhu Akbar).’” (Using translation from Tirmidhī 3509)   

السيوطي:٢٦٤٨a

"إذَا مَررْتُمْ برياضِ الجنَّةِ فارْتُعوا، قِيلَ: يا رسولَ الله! وما رياضُ الجنَّةِ؟ قال: المساجدُ، قِيلَ: وما الرَّتْعُ؟ قال: سُبْحانَ الله، والحمدُ لله، ولا إلهَ إلَّا الله والله أكبرُ".  

[ت] الترمذي غريب عن أبي هريرة

See similar narrations below:

Collected by Tirmidhī, Ṭabarānī
tirmidhi:3509Ibrāhīm b. Yaʿqūb > Zayd b. Ḥubāb > Ḥumayd al-Makkī a freed slave of Ibn ʿAlqamah > ʿAṭāʾ b. Abū Rabāḥ > Abū Hurayrah

“When you pass by the gardens of Paradise, then feast.” I said: “O Messenger of Allah, and what are the gardens of Paradise?” He said, “The Masajid.” I said: “And what is feasting, O Messenger of Allah?” He said: “‘Glory is to Allah, (Subḥān Allāh)’ and ‘All praise is due to Allah, (Al-Ḥamdulillāh)’ and ‘None has the right to be worshipped but Allah, (Lā Ilāha Illallāh)’ and ‘Allah is the Greatest (Allāhu Akbar).’”  

Abū ʿĪsá said that this Ḥadīth is Ḥasan-Gharīb.
الترمذي:٣٥٠٩حَدَّثَنَا إِبْرَاهِيمُ بْنُ يَعْقُوبَ حَدَّثَنَا زَيْدُ بْنُ حُبَابٍ أَنَّ حُمَيْدًا الْمَكِّيَّ مَوْلَى ابْنِ عَلْقَمَةَ حَدَّثَهُ أَنَّ عَطَاءَ بْنَ أَبِي رَبَاحٍ حَدَّثَهُ عَنْ أَبِي هُرَيْرَةَ قَالَ

قَالَ رَسُولُ اللَّهِ ﷺ إِذَا مَرَرْتُمْ بِرِيَاضِ الْجَنَّةِ فَارْتَعُوا قُلْتُ يَا رَسُولَ اللَّهِ وَمَا رِيَاضُ الْجَنَّةِ قَالَ الْمَسَاجِدُ قُلْتُ وَمَا الرَّتْعُ يَا رَسُولَ اللَّهِ قَالَ سُبْحَانَ اللَّهِ وَالْحَمْدُ لِلَّهِ وَلاَ إِلَهَ إِلاَّ اللَّهُ وَاللَّهُ أَكْبَرُ  

قَالَ أَبُو عِيسَى هَذَا حَدِيثٌ حَسَنٌ غَرِيبٌ
tabarani:11158al-Ḥasan b. ʿAlī al-Maʿmarī > Aḥmad b. al-ʿAbbās Ṣāḥib al-Shāmh > al-Ḥārith b. ʿAṭiyyah > Baʿḍ Aṣḥābinā > Ibn Abū Najīḥ > Mujāhid > Ibn ʿAbbās

[Machine] The Messenger of Allah ﷺ said: "When you pass by the gardens of Paradise, enjoy yourselves." It was asked, "O Messenger of Allah, what are the gardens of Paradise?" He replied, "The gatherings of knowledge."  

الطبراني:١١١٥٨حَدَّثَنَا الْحَسَنُ بْنُ عَلِيٍّ الْمَعْمَرِيُّ ثنا أَحْمَدُ بْنُ الْعَبَّاسِ صَاحِبُ الشامةِ ثنا الْحَارِثُ بْنُ عَطِيَّةَ ثنا بَعْضُ أَصْحَابِنَا عَنِ ابْنِ أَبِي نَجِيحٍ عَنْ مُجَاهِدٍ عَنِ ابْنِ عَبَّاسٍ قَالَ

قَالَ رَسُولُ اللهِ ﷺ «إِذَا مَرَرْتُمْ بِرِيَاضِ الْجَنَّةِ فَارْتَعُوا» قِيلَ يَا رَسُولَ اللهِ وَمَا رِيَاضُ الْجَنَّةِ قَالَ «مَجَالِسُ الْعِلْمِ»