The 30-year-old spent two years with the Hammers in between 2006 and 2008, with spells at Sunderland either side of that.

McCartney made 71 appearances for West Ham during that time, and is happy to become manager Sam Allardyce's sixth summer signing.

Asensio's Screamer Vs FC Barcelona
Asensio's Screamer Vs FC Barcelona
In one of Real Madrid's most outstanding performances at the Camp Nou, Los Blancos beat FC Barcelona 3-1 in the Spanish Supercup. Real were leading 2-1 after Cristiano Ronaldo's 80th minute goal, but just before the final whistle, we sealed the win with this beautiful Marco Asensio strike.
0 seconds of 43 secondsVolume 0%
Press shift question mark to access a list of keyboard shortcuts
00:00
00:43
00:43
 
keep watching
Watch more Real Madrid videos on OneFootball

"It`s brilliant to be coming back," he told www.whufc.com. "For me personally it will be great to be playing again for a club like West Ham. It is a big opportunity for me and I can't wait to get started again.

"I am looking forward to being part of the manager's squad and the club's push for promotion."

Having fallen down the pecking order at Sunderland, McCartney spent the majority of last season on loan with Leeds, but was not made a permanent offer after he was criticised by chairman Ken Bates for his attitude.