Singer Britney Spears has been ordered to undergo random drug and alcohol tests twice a week, according to court documents in her child custody dispute.
Ms Spears' performed at the MTV Video Music Awards last week
Los Angeles Superior Court judge Scott M Gordon said Ms Spears, 25, showed "a habitual, frequent and continuous use of controlled substances and alcohol".
He also ordered Ms Spears and her former husband Kevin Federline to complete a parenting class.
Mr Federline, 29, is seeking increased custody of their two young sons.
Ms Spears married Mr Federline in October 2004 and filed for divorce last November. The divorce was finalised on 30 July.
The two currently have equal custody of Sean Preston, two, and Jayden James, one.
The order, which was given on Monday, requires both parents to refrain from drinking and using drugs around their two young children and 12 hours before either cares for them.
Only Ms Spears was told she must to submit to testing.
Both parents are also prohibited from "making derogatory remarks" about each other in their children's presence, and from "using corporal punishment" to discipline them.
Each must complete the court's Parenting Without Conflict class, while Ms Spears must also meet a "parenting coach" for eight hours a week, who will report back to the court.
Lawyers for Ms Spears and Mr Federline had not commented, Associated Press reported.
In February, Ms Spears was admitted to a rehabilitation clinic after being photographed shaving her head, following the collapse of her marriage to Mr Federline.