A federal judge gave Michael Avenatti a choice Wednesday: If he wanted to represent his client Stormy Daniels in the federal investigation of President Donald Trump’s longtime attorney Michael Cohen, he had to end his “publicity tour” of TV appearances and aggressive tweets about the case.

Avenatti chose instead to drop the case. He was back on MSNBC talking about Cohen less than two hours later.

During the hearing Wednesday, Judge Kimba Wood had told Avenatti he could only have a formal role the case if he stopped publicly denouncing Trump’s lawyer in the media because doing so could potentially taint the jury’s views in a trial.

“I either want you to participate, or not be in the matter at all,” Wood told Avenatti, according to Courthouse News, who had a reporter in the hearing. “I don’t want you to have some existence in a limbo where you’re free to denigrate Mr. Cohen, and I believe potentially deprive him of a fair trial by tainting a jury pool.”

In a motion, Avenatti said he would reassess his decision if there was a hearing related to Daniels.

Avenatti will still represent Daniels in her lawsuit against Trump and Cohen, which was filed in Los Angeles last March, but was delayed following the raids on Cohen’s properties last month. Daniels, a porn star whose real name is Stephanie Clifford, is suing Trump and Cohen over the nondisclosure agreement she signed related the $130,000 payment she signed before the 2016 election over her claims she had an affair with Trump.

Federal investigators raided Cohen’s office, hotel and apartment last month with search warrants partially obtained after a referral from special counsel Robert Mueller. Cohen came under a barrage of legal scrutiny after he conceded using personal funds to arrange the payment to Daniels just weeks before the election to prevent her from speaking out about her alleged affair with Trump. Trump subsequently admitted he had reimbursed Cohen for the payment, raising questions about campaign finance violations. According to the Washington Post, Cohen is now under investigation for bank fraud, wire fraud, and campaign finance violations.

In addition to his frequent appearances on cable news, Avenatti drove headlines three weeks ago when he tweeted information alleging Cohen had received payments of over $500,000 from a firm linked to a Russian oligarch and U.S. companies lobbying the government, including AT&T and Novartis. Although the payments were largely confirmed by three news outlets and the companies themselves, Avenatti has come under scrutiny for publicizing private documents.

Cohen’s attorneys argued in court that Avenatti should not be granted involvement because he has worked to publicly taint Cohen. Avenatti told Wood he had not been accused of any improper conduct, according to Courthouse News, but she responded that he would “need to stop doing some of the things you’ve been doing.”

Avenatti gave a brief statement to reporters outside the courtroom once the hearing was finished, but focused on the documents that were the subject of the hearing in relation to attorney-client privilege, arguing that Cohen and his attorneys should release all audio recordings.

He did not mention the judge’s order on this topic, and did not take questions from reporters immediately following the statement. When reached for comment after the hearing, Avenatti declined to say anything about that pronouncement from the judge, and told TIME he had another phone call he needed to take when asked if he would cut down on his cable news appearances. (Shortly afterwards, he appeared on MSNBC).

Pressed again Wednesday afternoon by TIME, he said he had withdrawn the motion because it was not necessary at this time. He said he was unperturbed by Woods’ assessment, and had no plans to change his strategy. “It didn’t bother me one bit,” he said. “We’re gonna continue doing what were doing. Its been very effective.”

Get our Politics Newsletter. The headlines out of Washington never seem to slow. Subscribe to The D.C. Brief to make sense of what matters most. Please enter a valid email address. Sign Up Now Check the box if you do not wish to receive promotional offers via email from TIME. You can unsubscribe at any time. By signing up you are agreeing to our Terms of Use and Privacy Policy . This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply. Thank you! For your security, we've sent a confirmation email to the address you entered. Click the link to confirm your subscription and begin receiving our newsletters. If you don't get the confirmation within 10 minutes, please check your spam folder.

Write to Alana Abramson at Alana.Abramson@time.com.