All perfect praise be to Allah, The Lord of the Worlds. I testify that there is none worthy of worship except Allah and that Muhammad is His slave and Messenger.
There is no basis for this Hadeeth. It is a lie and it is fabricated, so it is not correct to attribute it to the Prophet .
As-Suyooti said in az-Ziyaadaat ‘ala al-Mawdhoo’aat:
“I found at the back of a copy of Ibn Abu Shaybah, with a Moroccan handwriting, and I do not know the name of its writer, what reads: “... Anas ibn Maalik said: "The Prophet said: “When a man mounts another man, the Throne (of Allah) shakes and the heavens would say: ‘O Lord! Let us stone him’, and the earth would say: ‘O Lord! Let us swallow him.’ Allah would say: “Leave him as his destination (fate) is to Me, and he will stand in front of Me.”
Others have written below this Hadeeth what reads: “Its chain of narrators is unfounded, and its wording is fabricated.”
Besides, Ash-Shawkaani said in al-Fawaa'id al-Majmoo’ah fi al-Ahadeeth al-Mawdhoo’ah:
“The Hadeeth “When a man mounts another man, the throne of Allah shakes and the heavens would say: ‘O Lord! Let us stone him’, and the earth would say: ‘O Lord! Let us swallow him.’, is fabricated.” [End of quote]
Allah knows best.