The traditional route is to use magic items. In earlier editions, planning was virtually pointless, because you could never account for which magic items you happened to find. You might not imagine your fighter as gaining fire magic, but if you trip over the sword and necklace, then I guess you're Talon Flamebrand.
I'm imagining something similar for class levels. Instead of experience, maybe you need material reagents to unlock the next level in each class, and those aren't available on the open market. If you end up finding enough level one rubies, then somebody in the party can gain their first level of pyromancer, and there's no good reason for them not to do so.