U.S. actor Mark Salling arrives at the Entertainment Tonight Emmy Party in Los Angeles, California, U.S. September 19, 2011.
U.S. actor Mark Salling arrives at the Entertainment Tonight Emmy Party in Los Angeles, California, U.S. September 19, 2011. Reuters/Jason Redmond/File Photo

“Glee” star Mark Salling has pleaded guilty to possession of child pornography involving a prepubescent minor. The 35-year-old actor agreed to serve four to seven years in prison as part of his plea bargain.

The plea agreement states that Salling will be registered as a sex offender and prohibited to communicate with anyone aged under 18 years old unless there’s a parent or legal guardian present. He was facing a maximum of 20 years without the plea agreement.

According to the documents obtained by The Blast, he will also be under supervised released for 20 years after his prison sentence. He must adhere to guidelines, stay 100 feet away from schoolyards and parks, playgrounds, video arcade facilities and public swimming pools. He will also pay US$50,000 (AU$63,900) restitution to each victim who has requested it.

The plea agreement is yet to be accepted by the judge. Salling will face trial on Oct. 17.

The American actor/singer was arrested in December 2015 on suspicion of possessing more than 50,000 photos and videos depicting child pornography on his laptop and 4,000 images on a flash drive. He was charged the following May with receiving and possessing the materials. He apparently used software to hide his IP address but showed the materials to an adult woman on at least two occasions. The woman then reported him to the police.

His indictment led to his removal from the cast of the miniseries “Gods and Secrets,” with director Adi Shankar pledging a percentage of profits from the show to a charity for abused children. He previously pleaded not guilty to the charges.

Salling is best known for his role as Puck on the musical comedy series “Glee,” which ran its final episode in March 2015. His ex-girlfriend and co-star Naya Rivera wrote on her book “Sorry, Not Sorry” that she wasn’t surprised he got into trouble, but the gravity of his crime was still appalling.

“I can’t say I was totally shocked, but still – WTF?” she wrote. “My son’s nanny actually told me about it when the story broke. Then I had no doubt that God really did have my back along the way.”

They met on the set of the show and broke up in 2010 when Salling’s publicist allegedly told him she was bad for his image. She wrote how devastated she was when he broke up with her, but accepted it as a lesson, and that she wouldn’t regret the relationship. “Unless, of course, that relationship was with someone who had a sizable stash of child porn on his computer. Then, by all means, regret everything.”