The stay should not post if your name is on the res. but you do not check in.
Also, the hotel 'may' provide your benefits, but they certainly are not obliged to do so.
At check in, when they ID the person checking in the room, (which needs to be done so they know 'who' is actually staying in room) if they hotel changes the name on the reservation (as they should), it's no longer your reservation and you will not earn points/credit for this.
You earn points/credit for
your stays
and when
you are paying (not one or the other) and certainly not when you try to scheme the hotel into giving your benefits to another because you put your number on their reservation so you could collect credit.
People trying the cheat the system only deteriorates it for themselves and others.