Redmond O'Neal Redmond O'Neal

Redmond O'Neal, the son of Farrah Fawcett and Ryan O'Neal, will take part in a drug rehabilitation program in hopes of avoiding prison.

O'Neal was ordered to participate in a yearlong intensive rehabilitation program Thursday. If he successfully completes it, he would be removed from probation and his drug-conviction record would be wiped clean. If he fails, O'Neal could face several years in prison.

The program involves frequent drug-testing, group counseling, court appearances and a 12-step program. O'Neal must also get a job.  

"This is an opportunity to change your life," Assistant District Attorney Tony Estradas said in court. "Our goal is for you to enjoy a long, healthy life that is free from addiction."

O'Neal, 24, who has been in custody since April 5 after violating the terms of his probation, also pleaded not guilty to a separate heroin possession charge.

Last weekend, O'Neal was granted temporarily leave from jail to visit his ailing mother, who is battling cancer.

Follow TV Guide on Twitter for breaking news and scoop.