WASHINGTON — President Barack Obama signed legislation Wednesday barring members of Congress, the president and thousands of federal workers from insider trading and profiting from nonpublic information learned on the job.

The new law lets the public see more of government officials’ financial dealings. Lawmakers abandoned an earlier proposal to require public reports from people who gather information from Congress and sell it, mostly to investors.

The driving force behind the bill was Congress’ attempt to boost dismal approval ratings, with polls showing between 12 percent and 19 percent of Americans approve the job Congress is doing.