There's a lot of truth in this.
In some jobs in the private sector, such as law, there are set pay scales at junior levels and you can look up what individual firms pay, e.g. a first year trainee, a second year trainee, a newly qualified solicitor, a NQ+1 etc. for the first few years. After that it's "dependent on performance" and there's no more transparency. I'm guessing that's the moment where the men start to pull ahead significantly, especially since it coincides with the time a lot of women start taking maternity leaves.
Where I work (in law but not in a law firm and not in the UK) we don't tend to discuss our salaries in detail but there is no general rule about it. My manager told me that he knows how much his female counterpart owns and vice versa, so clearly it would be OK for me to discuss my own salary with other team members.
A few years ago a guy joined my team from a well known company in a high paying sector. My manager told me that my salary was higher than this guy's, but I have no way of knowing whether that was true or not. My manager probably thought he could rely on me not asking the other guy because we hated each other. And I thought there was no point in asking him because he would definitely have lied and told me he was on more than he was actually on. He lied about everything, including on his CV. Amazingly, he put on his CV that he speaks fluent Spanish, which he definitely doesn't, and got away with it despite the fact that our boss is half Spanish and could have tested him at any time. He's now left, and is earning megabucks somewhere else, but frankly I'm just glad he's gone.
Last year my manager and his female counterpart did a benchmarking exercise and went to senior management with a business case for our entire team getting a fairly substantial pay rise, due to the fact that our salaries were already lagging a little bit below the market and with inflation it was only going to get worse. We were told that everyone in the team would be getting a percentage rise based on our level of seniority, with the more junior members getting a higher percentage pay rise because they were on lower salaries. We were told not to discuss it with anyone outside the team, or with people in our sister companies, because the company couldn't afford to do the same for everyone.