Kirk became a flag officer in 2270 upon completion of the USS Enterprise's five-year mission. Kirk remained Admiral until he was demoted at the end of Star Trek IV: The Voyage Home, in 2286.
Shockingly, Riker did not get his pips to become a flag officer. Admiral Riker commanding the USS Enterprise-D was seen in ...