The trial court properly denied plaintiff attorney fees under CCP 1021.5 when it obtained a preliminary injunction requiring Prop. 65 warnings on coffee but later lost on summary judgment. The temporary warnings did not confer any substantial benefit on the general public. The Coffee Regulation later adopted by the agency responsible for Prop. 65 showed that coffee poses no significant risk of causing cancer, So the temporary warnings disserved Prop. 65’s purposes by distracting consumers with inappropriate warnings.