But only when he himself is in communion with the Magisterium of the Church.
you're implying that at times, Peter does not loose what is loosed in heaven, nor bind what is bound in heaven on matters of faith. Because, if you're saying it's even POSSIBLE that Peter can be out out of communinon with the Magisterium, then that throws doubt on the entire Catholic faith from Day One - and if that's the case, then the Church is a fraud, and Jesus was a liar.
Pope John the 22nd. (not the 23rd) preached from the pulpit that no one who had already died was in the presence of God. But that they would only see God after the final judgment.
He was questioned, rebuked and resisted in this error by his own subordinates until finally on his deathbed he recanted.
His preaching and ideas were not an act of the Magisterium.