Many companies manufacture handrails and guardrails to prevent slips in bathrooms for seniors. However, in almost every case the dimensions of the rail or the the supports in the wall (studs) are not set up to give proper support.
In this picture, you see a typical situation and how it was solved. The guardrail was 24 inches long. However, most wall studs are 16 inches apart and therefore even if you can find one of the studs, there is no chance of fastening the both sides of the rail to a solid stud. As well, depending on the building, there is a very good chance that there are no wooden studs at all. In this case, there was one metal stud and nowhere to fasten the rail. The previous installer just used drywall plugs which can then come out and cause a serious accident.
The proper way to install in this case is to find two solid supports (the studs near the shower stall and the door frame) and then install a support board completely across the width. Then, fasten the guardrail securely to the support board. The result? A completely solid handrail that can support someone when they are getting out of the shower and no slips!