California Penal Code
(a) Upon the conviction of a defendant for a sexual offense involving a minor victim or, in the case of a minor appearing in juvenile court, if a petition is admitted or sustained for a sexual offense involving a minor victim, the court is authorized to issue orders that would prohibit the defendant or juvenile, for a period up to 10 years, from harassing, intimidating, or threatening the victim or the victim’s family members or spouse.
(b) No order issued pursuant to this section shall be interpreted to apply to counsel acting on behalf of the defendant or juvenile, or to investigators working on behalf of counsel, in an action relating to a conviction, petition in juvenile court, or any civil action arising therefrom,
provided, however, that no counsel or investigator shall harass or threaten any person protected by an order issued pursuant to subdivision (a).
(c) Notice of the intent to request an order pursuant to this section shall be given to counsel for the defendant or juvenile by the prosecutor or the court at the time of conviction, or disposition of the petition in juvenile court, and counsel shall have adequate time in which to respond to the request before the order is made.
(d) A violation of an order issued pursuant to subdivision (a) is punishable as provided in Section 166.