Former "Glee" star Mark Salling pled guilty to possession of child pornography involving prepubescent minors on Tuesday. He will serve between four and seven years in prison.

As part of the plea, the actor will have to register as a sex offender, enter a treatment program, have no unsupervised contact with anyone under the age of 18 and stay away from schoolyards, parks, swimming pools, playgrounds and video arcades, according to court documents obtained by The Blast.

Salling, 35, was also ordered to pay $50,000 in restitution to each victim of the child pornography who has requested it.

The documents reveal that Salling knowingly downloaded thousands of images of child pornography between April and December 2015, hiding the activity with software that masked his IP address. He was eventually caught after he showed the images to a woman he was in a relationship with, who reported the actor to authorities.

Salling was arrested on Dec. 29, 2015, after a search of his Los Angeles-area home three days prior turned up thousands of files of child pornography on his laptop, a thumbnail drive and an encrypted hard drive.

Click for more from the New York Post.