US President Donald Trump has been mocked on social media for hypocrisy for a tweet in 2012 that accused the White House of a lack of transparency.

The Twitter backlash came as Trump's administration announced on Friday (14 April) that it would not release the White House visitor's log.

The decision appeared to contradict Trump's previous statements on the subject of presidents being transparent.

Social media posts he made in June and October 2012 slammed former president Barack Obama over the same topic.

Trump had written: "Why is ‪@BarackObama spending millions to try and hide his records? He is the least transparent President — ever — and he ran on transparency."

In another post, he tweeted:

His words came back to bite him this week after White House communications director Mike Dubke said visitor records would no longer be shared with the public.

Visitor log disclosures were started under former president Obama but Trump's administration said the practice now posed a security risk.

In a statement seen by The Hill, Dubke said there would no longer be such information shared because of the "the grave national security risks and privacy concerns of the hundreds of thousands of visitors annually".

But critics of the decision said voters should be informed about who is visiting the White House.

A number of social media users shared Trump's 2012 tweets, with many pointing out the incumbent president appears to be moving further away from the transparency of Obama's tenure despite his previous comments.