Victor Willis, who performed as the policeman in the 1970s disco band The Village People, has been given three years probation for drugs offences.
Willis was the lead singer with the group in the 1970s
Willis, who co-wrote some of the group's biggest hits - including YMCA and In The Navy - pleaded no contest to the charges, dating from March.
He was given an eight-month suspended jail sentence by a judge in California.
The suspension is on condition that he complete a course of drug treatment programmes over at least seven months.
The treatment will include a 30-day spell in the Betty Ford Center in Long Beach, California.
Structured and sound
Willis was arrested in March near San Francisco on drug and gun charges.
It was the latest in a series of run-ins that he has had with the police since leaving the Village People in 1980.
He has been undergoing drug abuse treatment in San Mateo County since his arrest.
He lawyer Mark Geragos told the judge that Willis is making progress in treatment and is serious about making a recovery.
The judge, Mark Forcum, said Willis "needs to be in a programme that is structured and sound" but warned him that he would go to prison if he violated his probation.