When a Muslim commits a sin, particularly one which is punishable by a specific punishment, he should not publicize what he has done.
Publicity is an additional sin.
If he makes a confession of what he had done, the punishment prescribed by Allah must be enforced. To make such a confession is permissible, but the Prophet teaches us that a person who commits a sin should not lift the mantle with which Allah has covered it. Therefore, a person who commits adultery should not publicize that. If he has a child born to him illegitimately and he marries the mother of the child, no one will ask him about the legitimacy of the child. The relationship between an illegitimate child and his father is broken.