Praise be to Allah, and may peace and blessings be upon the Messenger of Allah. To proceed:
The basic principle is that a Muslim should choose righteous companions who help him obey Allah. The Prophet ﷺ said: “A person follows the religion of his close friend, so let each of you consider whom he takes as a close friend.”
If your friend has fallen into deviations in belief, religious innovations, or sins, then you should advise him with gentleness and wisdom, explain the truth to him based on the Qur’an, the Sunnah, and the understanding of the righteous predecessors of the Muslim Ummah, and pray to Allah to guide him.
Should you continue being his friend?
If you are a person of knowledge and insight, and you hope that you can positively influence him without being influenced by his ideas, there is no harm in continuing to communicate with him with the intention of inviting him to the truth and helping him reform.
However, if you find that his companionship negatively affects your religion, weakens your faith, or causes you to fall into doubts and misconceptions, then you should reduce your contact with him or end the relationship, because safeguarding one’s religion takes precedence over everything else.
How should you advise him?
You should encourage him to learn the correct Islamic creed and adhere to the Qur’an and the authentic Sunnah. You should also explain to him that being a wali (a righteous close servant of Allah) is not established through mere claims; rather, it is attained through faith, piety, and following the Prophet ﷺ. Opposing the Sunnah or neglecting religious obligations is not a path to drawing closer to Allah.
Conclusion
If remaining in contact with him serves the beneficial purpose of inviting him to the truth without harming your own religion, then continue advising him with wisdom and patience. But if you fear that his misguidance may influence you or weaken your faith, then distance yourself from him and choose righteous companions who help you obey Allah.
And Allah knows best.