A former teacher has been cleared of attempting to procure a child for sex after a magistrate heard he was the victim of vigilante pedophile hunters.