My bike won't shift out of 7th gear in the back
Assuming you did not have a fall and it was working well in the recent past and it does shift but not correctly then you just have to adjust the tension on the cables. What you are describing seems normal some adjustments on your bike are due after some use. If adjustments cannot fix I would then check the cable condition and derailleur function.

The cables needs to have a certain strech so it can move the derailleur far enough to reach all gears. And yes it is also not suprising that the strech changes when a rider is on the bike, your weight and motion streches the frame and cables and they may behave differently especially if not well tuned or are too old. You more likely just have to adjust - again, unless something out of the ordinary occured which is not mentioned.

Most bikes have a fine adjuster which can adjust the tension by just turning a knob (barrel adjuster) without tools even while you are on the road. If this is not enough just adjust the cable tension with tools. Then try all your gears to make sure all shift fine.

If your rear does not shift at all then this is an indication that your cables are getting stopped or impeded somewhere when the rider is on the bike. Run visually the cables from your shifter up to your rear derailleur and find where their movement seems impeded (especially if you have rear suspension have someone sit on the bike when you do that). For example some cable guides or ferrules may have been worn out on one end and when someone sits the cable runs through that part and gets impeded by the wear. If you cannot find the wear run full new cable set (should be fairly inexpensive).