Is it permissible for ordinary Muslims to say “O Allah, forgive me, have mercy on me and join me to the higher companions”?
Question

                I was wondering if it is permissable for ordinary Muslims like myself to make the du'a that the Prophet (sal Allahu 'alayhi wa sallam) made near his death : Allaahumma aghfirlee warhamnee wa alhiqnee birafeeq il-'ala
Praise be to Allah.Firstly: 
Al-Bukhaari (5674) and Muslim (2191) narrated that ‘Aa’ishah (may Allah be pleased with her) said: I heard the Prophet (blessings and peace of Allah be upon him) say, when he was leaning on my chest: “O Allah, forgive me, have mercy on me and join me to the higher companions.” 
What is meant by “the higher companions” is to be with those whom Allah has blessed of the Prophets, the siddeeqs, the martyrs and the righteous, in the highest gardens of delight (Paradise). When a righteous person is joined to the higher companions, he will go to his level, so the Prophet will be with the Prophets, the siddeeq will be with the siddeeqs, and the righteous person will be with the righteous. 
It was narrated that ‘Aa’ishah (may Allah be pleased with her) said: I used to hear that no Prophet ever died until he had been given the choice between this world and the Hereafter. I heard the Prophet (blessings and peace of Allah be upon him), during the sickness of which he died, saying with some gruffness in his voice: “in the company of those on whom Allah has bestowed His Grace, of the Prophets, the Siddeeqoon (those followers of the Prophets who were first and foremost to believe in them, like Abu Bakr As‑Siddeeq رضى الله عنه ), the martyrs, and the righteous. And how excellent these companions are!” [al-Nisa’ 4:69].
She said: And I thought that he had been given the choice at that point.
Narrated by al-Bukhaari (4435) and Muslim (2444) 
Ibn ‘Abd al-Barr (may Allah have mercy on him) said: 
With regard to the phrase “and join me to the higher companions”, in their view it is a reference to the verse in which Allah, may He be glorified and exalted, says (interpretation of the meaning): “in the company of those on whom Allaah has bestowed His Grace, of the Prophets, the Siddeeqoon, the martyrs, and the righteous. And how excellent these companions are!” [al-Nisa’ 4:69].
End quote from al-Istidhkaar (3/85). 
Ibn Katheer (may Allah have mercy on him) said:
This is what is meant by what the Prophet (blessings and peace of Allah be upon him) said in the other hadeeth: “O Allah, with the higher companions” three times.
End quote from Tafseer Ibn Katheer (2/353) 
Al-Haafiz Ibn Hajar (may Allah have mercy on him) said:
I came across some additional material via Ahmad ibn Harb from Muslim ibn Ibraaheem, the shaykh of al-Bukhaari, after the words “during the sickness of which he died, saying with some gruffness in his voice”: I began to hear him say, “With the higher companions, in the company of those on whom Allah has bestowed His Grace, of the Prophets …”
End quote from Fath al-Baari (8/137). 
Based on that, the basic principle is that there is nothing wrong with a person asking his Lord to join him with the higher companions when he dies, and to cause him to reach the level of the righteous; that du‘aa’ is not something that is only for the Prophets. 
It was narrated that Zayd ibn Aslam said: al-Miswar ibn Makhramah fell unconscious, then he came to and said: “I bear witness that there is no god but Allah and that Muhammad is the Messenger of Allah. Being close to Allah is dearer to me than this world and everything in it. ‘Abd ar-Rahmaan ibn ‘Awf is among the higher companions, “in the company of those on whom Allah has bestowed His Grace, of the Prophets, the Siddeeqoon, the martyrs, and the righteous. And how excellent these companions are!” [al-Nisa’ 4:69]. 
Narrated by Ibn Abi Dunyah in Kitaab al-Muhtadareen (p. 358); its isnaad is saheeh. 
The scholars of the Standing Committee said: 
Allah has forbidden the earth to consume the bodies of the Prophets and Messengers, so they remain as they were, and they are alive in their graves in the sense of the life of al-barzakh, and Allah knows best how it is. It is not like their life in this world, and their souls are in Paradise. The same applies to the souls of the believers and the soul of our Prophet Muhammad among the higher companions in Paradise.
End quote from Fataawa al-Lajnah ad-Daa’imah (2/443). 
Secondly: 
This du‘aa’ should not be said except in two cases: 
1.When death is actually approaching and the individual knows that he is dying. In that case there is nothing wrong with saying this du‘aa’. 
Al-Bukhaari (5673) and Muslim (2682) narrated from Abu Hurayrah that the Messenger of Allah (blessings and peace of Allah be upon him) said: “No one of you should wish for death or pray for it before it comes to him.” 
Al-Haafiz (may Allah have mercy on him) said: 
What we understand from this is that when death becomes imminent, there is nothing wrong with wishing for it, out of longing to meet Allah. For this sulte reason al-Bukhaari commented the hadeeth of Abu Bakr by quoting the hadeeth of ‘Aa’ishah, “O Allah, forgive me, have mercy on me and join me to the higher companions”, to indicate that the prohibition applies specifically to cases before death approaches. End quote. 
2.When what the individual means by saying that is “When death comes to me, then join me to the higher companions.” 
This was the supplication of Ibraaheem al-Khaleel (peace be upon him): “My Lord! Bestow Hukman (religious knowledge, right judgement of the affairs and Prophethood) on me, and join me with the righteous” [ash-Shu‘ara’ 26:83]. 
Ibn Katheer said:
That is, join me with the righteous in this world and in the Hereafter, as the Prophet (blessings and peace of Allah be upon him) said when he was dying, “O Allah, the higher companions.” He said it three times.
End quote from Tafseer Ibn Katheer (6/147) 
If a person asks for this, he must strive hard in doing righteous deeds so that Allah will help him to join the higher companions, when He takes his soul, for Allah, may He be exalted, has stipulated that in order to attain that high status, the individual must make a commitment to obey Allah and His Messenger, as He, may He be exalted, says (interpretation of the meaning):
“And whoso obeys Allah and the Messenger (Muhammad blessings and peace of Allah be upon him), then they will be in the company of those on whom Allah has bestowed His Grace, of the Prophets, the Siddiqoon (those followers of the Prophets who were first and foremost to believe in them, like Abu Bakr As-Siddiq ), the martyrs, and the righteous. And how excellent these companions are!
Such is the Bounty from Allah, and Allah is Sufficient as All-Knower”
[an-Nisa’ 4:69-70]. 
Ibn Katheer (may Allah have mercy on him) said:
That is, everyone who obeys Allah and His Messenger according to his ability and does what he is enjoined to do, male or female, young or old, “then they will be in the company of those on whom Allah has bestowed His Grace” namely the immense blessing which implies perfection, success and happiness.
End quote from Tafseer Ibn Katheer (1/185) 
For more information, please see the answers to questions no. 45841, 46592 and 145721.
And Allah knows best.