FATHUL BARI

(Fathul Bari chap on Anbiya).
From all the above Ahadith it is proven that the Prophet (May Allah bless him and grant him peace) was bestowed with more knowledge, than any other in the creation by Allah Almighty. It is also clear that he, (May Allah bless him and grant him peace), has been bestowed with the knowledge of the past and future and it is therefore permissible to say that Prophet Muhammad (May Allah bless him and grant him peace) is the trustee of the knowledge of Ghayb.
It is proven from the above narrations that Allah Almighty bestowed (that is gave) our Prophet (May Allah bless him and grant him peace) the knowledge of the Ghayb, so it is permissible to say that he, (May Allah bless him and grant him peace) knows the Ghayb. Hence if someone says that they hold the Prophet to know the Ghayb(unseen), he is not committing Kufr or Shirk by holding such a belief.